{-# 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.ModelClientConfig
-- 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.ModelClientConfig 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 timeout and maximum number of retries for processing a
-- transform job invocation.
--
-- /See:/ 'newModelClientConfig' smart constructor.
data ModelClientConfig = ModelClientConfig'
  { -- | The maximum number of retries when invocation requests are failing. The
    -- default value is 3.
    ModelClientConfig -> Maybe Natural
invocationsMaxRetries :: Prelude.Maybe Prelude.Natural,
    -- | The timeout value in seconds for an invocation request. The default
    -- value is 600.
    ModelClientConfig -> Maybe Natural
invocationsTimeoutInSeconds :: Prelude.Maybe Prelude.Natural
  }
  deriving (ModelClientConfig -> ModelClientConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModelClientConfig -> ModelClientConfig -> Bool
$c/= :: ModelClientConfig -> ModelClientConfig -> Bool
== :: ModelClientConfig -> ModelClientConfig -> Bool
$c== :: ModelClientConfig -> ModelClientConfig -> Bool
Prelude.Eq, ReadPrec [ModelClientConfig]
ReadPrec ModelClientConfig
Int -> ReadS ModelClientConfig
ReadS [ModelClientConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ModelClientConfig]
$creadListPrec :: ReadPrec [ModelClientConfig]
readPrec :: ReadPrec ModelClientConfig
$creadPrec :: ReadPrec ModelClientConfig
readList :: ReadS [ModelClientConfig]
$creadList :: ReadS [ModelClientConfig]
readsPrec :: Int -> ReadS ModelClientConfig
$creadsPrec :: Int -> ReadS ModelClientConfig
Prelude.Read, Int -> ModelClientConfig -> ShowS
[ModelClientConfig] -> ShowS
ModelClientConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ModelClientConfig] -> ShowS
$cshowList :: [ModelClientConfig] -> ShowS
show :: ModelClientConfig -> String
$cshow :: ModelClientConfig -> String
showsPrec :: Int -> ModelClientConfig -> ShowS
$cshowsPrec :: Int -> ModelClientConfig -> ShowS
Prelude.Show, forall x. Rep ModelClientConfig x -> ModelClientConfig
forall x. ModelClientConfig -> Rep ModelClientConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ModelClientConfig x -> ModelClientConfig
$cfrom :: forall x. ModelClientConfig -> Rep ModelClientConfig x
Prelude.Generic)

-- |
-- Create a value of 'ModelClientConfig' 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:
--
-- 'invocationsMaxRetries', 'modelClientConfig_invocationsMaxRetries' - The maximum number of retries when invocation requests are failing. The
-- default value is 3.
--
-- 'invocationsTimeoutInSeconds', 'modelClientConfig_invocationsTimeoutInSeconds' - The timeout value in seconds for an invocation request. The default
-- value is 600.
newModelClientConfig ::
  ModelClientConfig
newModelClientConfig :: ModelClientConfig
newModelClientConfig =
  ModelClientConfig'
    { $sel:invocationsMaxRetries:ModelClientConfig' :: Maybe Natural
invocationsMaxRetries =
        forall a. Maybe a
Prelude.Nothing,
      $sel:invocationsTimeoutInSeconds:ModelClientConfig' :: Maybe Natural
invocationsTimeoutInSeconds = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of retries when invocation requests are failing. The
-- default value is 3.
modelClientConfig_invocationsMaxRetries :: Lens.Lens' ModelClientConfig (Prelude.Maybe Prelude.Natural)
modelClientConfig_invocationsMaxRetries :: Lens' ModelClientConfig (Maybe Natural)
modelClientConfig_invocationsMaxRetries = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModelClientConfig' {Maybe Natural
invocationsMaxRetries :: Maybe Natural
$sel:invocationsMaxRetries:ModelClientConfig' :: ModelClientConfig -> Maybe Natural
invocationsMaxRetries} -> Maybe Natural
invocationsMaxRetries) (\s :: ModelClientConfig
s@ModelClientConfig' {} Maybe Natural
a -> ModelClientConfig
s {$sel:invocationsMaxRetries:ModelClientConfig' :: Maybe Natural
invocationsMaxRetries = Maybe Natural
a} :: ModelClientConfig)

-- | The timeout value in seconds for an invocation request. The default
-- value is 600.
modelClientConfig_invocationsTimeoutInSeconds :: Lens.Lens' ModelClientConfig (Prelude.Maybe Prelude.Natural)
modelClientConfig_invocationsTimeoutInSeconds :: Lens' ModelClientConfig (Maybe Natural)
modelClientConfig_invocationsTimeoutInSeconds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModelClientConfig' {Maybe Natural
invocationsTimeoutInSeconds :: Maybe Natural
$sel:invocationsTimeoutInSeconds:ModelClientConfig' :: ModelClientConfig -> Maybe Natural
invocationsTimeoutInSeconds} -> Maybe Natural
invocationsTimeoutInSeconds) (\s :: ModelClientConfig
s@ModelClientConfig' {} Maybe Natural
a -> ModelClientConfig
s {$sel:invocationsTimeoutInSeconds:ModelClientConfig' :: Maybe Natural
invocationsTimeoutInSeconds = Maybe Natural
a} :: ModelClientConfig)

instance Data.FromJSON ModelClientConfig where
  parseJSON :: Value -> Parser ModelClientConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ModelClientConfig"
      ( \Object
x ->
          Maybe Natural -> Maybe Natural -> ModelClientConfig
ModelClientConfig'
            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
"InvocationsMaxRetries")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"InvocationsTimeoutInSeconds")
      )

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

instance Prelude.NFData ModelClientConfig where
  rnf :: ModelClientConfig -> ()
rnf ModelClientConfig' {Maybe Natural
invocationsTimeoutInSeconds :: Maybe Natural
invocationsMaxRetries :: Maybe Natural
$sel:invocationsTimeoutInSeconds:ModelClientConfig' :: ModelClientConfig -> Maybe Natural
$sel:invocationsMaxRetries:ModelClientConfig' :: ModelClientConfig -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
invocationsMaxRetries
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
invocationsTimeoutInSeconds

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