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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 timeout value in seconds for an invocation request.
    ModelClientConfig -> Maybe Natural
invocationsTimeoutInSeconds :: Prelude.Maybe Prelude.Natural,
    -- | The maximum number of retries when invocation requests are failing.
    ModelClientConfig -> Maybe Natural
invocationsMaxRetries :: Prelude.Maybe Prelude.Natural
  }
  deriving (ModelClientConfig -> ModelClientConfig -> Bool
(ModelClientConfig -> ModelClientConfig -> Bool)
-> (ModelClientConfig -> ModelClientConfig -> Bool)
-> Eq ModelClientConfig
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]
(Int -> ReadS ModelClientConfig)
-> ReadS [ModelClientConfig]
-> ReadPrec ModelClientConfig
-> ReadPrec [ModelClientConfig]
-> Read 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
(Int -> ModelClientConfig -> ShowS)
-> (ModelClientConfig -> String)
-> ([ModelClientConfig] -> ShowS)
-> Show ModelClientConfig
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. ModelClientConfig -> Rep ModelClientConfig x)
-> (forall x. Rep ModelClientConfig x -> ModelClientConfig)
-> Generic ModelClientConfig
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:
--
-- 'invocationsTimeoutInSeconds', 'modelClientConfig_invocationsTimeoutInSeconds' - The timeout value in seconds for an invocation request.
--
-- 'invocationsMaxRetries', 'modelClientConfig_invocationsMaxRetries' - The maximum number of retries when invocation requests are failing.
newModelClientConfig ::
  ModelClientConfig
newModelClientConfig :: ModelClientConfig
newModelClientConfig =
  ModelClientConfig' :: Maybe Natural -> Maybe Natural -> ModelClientConfig
ModelClientConfig'
    { $sel:invocationsTimeoutInSeconds:ModelClientConfig' :: Maybe Natural
invocationsTimeoutInSeconds =
        Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:invocationsMaxRetries:ModelClientConfig' :: Maybe Natural
invocationsMaxRetries = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The timeout value in seconds for an invocation request.
modelClientConfig_invocationsTimeoutInSeconds :: Lens.Lens' ModelClientConfig (Prelude.Maybe Prelude.Natural)
modelClientConfig_invocationsTimeoutInSeconds :: (Maybe Natural -> f (Maybe Natural))
-> ModelClientConfig -> f ModelClientConfig
modelClientConfig_invocationsTimeoutInSeconds = (ModelClientConfig -> Maybe Natural)
-> (ModelClientConfig -> Maybe Natural -> ModelClientConfig)
-> Lens
     ModelClientConfig ModelClientConfig (Maybe Natural) (Maybe Natural)
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)

-- | The maximum number of retries when invocation requests are failing.
modelClientConfig_invocationsMaxRetries :: Lens.Lens' ModelClientConfig (Prelude.Maybe Prelude.Natural)
modelClientConfig_invocationsMaxRetries :: (Maybe Natural -> f (Maybe Natural))
-> ModelClientConfig -> f ModelClientConfig
modelClientConfig_invocationsMaxRetries = (ModelClientConfig -> Maybe Natural)
-> (ModelClientConfig -> Maybe Natural -> ModelClientConfig)
-> Lens
     ModelClientConfig ModelClientConfig (Maybe Natural) (Maybe Natural)
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)

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

instance Prelude.Hashable ModelClientConfig

instance Prelude.NFData ModelClientConfig

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