{-# 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.AsyncInferenceConfig
-- 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.AsyncInferenceConfig 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.AsyncInferenceClientConfig
import Amazonka.SageMaker.Types.AsyncInferenceOutputConfig

-- | Specifies configuration for how an endpoint performs asynchronous
-- inference.
--
-- /See:/ 'newAsyncInferenceConfig' smart constructor.
data AsyncInferenceConfig = AsyncInferenceConfig'
  { -- | Configures the behavior of the client used by SageMaker to interact with
    -- the model container during asynchronous inference.
    AsyncInferenceConfig -> Maybe AsyncInferenceClientConfig
clientConfig :: Prelude.Maybe AsyncInferenceClientConfig,
    -- | Specifies the configuration for asynchronous inference invocation
    -- outputs.
    AsyncInferenceConfig -> AsyncInferenceOutputConfig
outputConfig :: AsyncInferenceOutputConfig
  }
  deriving (AsyncInferenceConfig -> AsyncInferenceConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AsyncInferenceConfig -> AsyncInferenceConfig -> Bool
$c/= :: AsyncInferenceConfig -> AsyncInferenceConfig -> Bool
== :: AsyncInferenceConfig -> AsyncInferenceConfig -> Bool
$c== :: AsyncInferenceConfig -> AsyncInferenceConfig -> Bool
Prelude.Eq, ReadPrec [AsyncInferenceConfig]
ReadPrec AsyncInferenceConfig
Int -> ReadS AsyncInferenceConfig
ReadS [AsyncInferenceConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AsyncInferenceConfig]
$creadListPrec :: ReadPrec [AsyncInferenceConfig]
readPrec :: ReadPrec AsyncInferenceConfig
$creadPrec :: ReadPrec AsyncInferenceConfig
readList :: ReadS [AsyncInferenceConfig]
$creadList :: ReadS [AsyncInferenceConfig]
readsPrec :: Int -> ReadS AsyncInferenceConfig
$creadsPrec :: Int -> ReadS AsyncInferenceConfig
Prelude.Read, Int -> AsyncInferenceConfig -> ShowS
[AsyncInferenceConfig] -> ShowS
AsyncInferenceConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AsyncInferenceConfig] -> ShowS
$cshowList :: [AsyncInferenceConfig] -> ShowS
show :: AsyncInferenceConfig -> String
$cshow :: AsyncInferenceConfig -> String
showsPrec :: Int -> AsyncInferenceConfig -> ShowS
$cshowsPrec :: Int -> AsyncInferenceConfig -> ShowS
Prelude.Show, forall x. Rep AsyncInferenceConfig x -> AsyncInferenceConfig
forall x. AsyncInferenceConfig -> Rep AsyncInferenceConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AsyncInferenceConfig x -> AsyncInferenceConfig
$cfrom :: forall x. AsyncInferenceConfig -> Rep AsyncInferenceConfig x
Prelude.Generic)

-- |
-- Create a value of 'AsyncInferenceConfig' 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:
--
-- 'clientConfig', 'asyncInferenceConfig_clientConfig' - Configures the behavior of the client used by SageMaker to interact with
-- the model container during asynchronous inference.
--
-- 'outputConfig', 'asyncInferenceConfig_outputConfig' - Specifies the configuration for asynchronous inference invocation
-- outputs.
newAsyncInferenceConfig ::
  -- | 'outputConfig'
  AsyncInferenceOutputConfig ->
  AsyncInferenceConfig
newAsyncInferenceConfig :: AsyncInferenceOutputConfig -> AsyncInferenceConfig
newAsyncInferenceConfig AsyncInferenceOutputConfig
pOutputConfig_ =
  AsyncInferenceConfig'
    { $sel:clientConfig:AsyncInferenceConfig' :: Maybe AsyncInferenceClientConfig
clientConfig =
        forall a. Maybe a
Prelude.Nothing,
      $sel:outputConfig:AsyncInferenceConfig' :: AsyncInferenceOutputConfig
outputConfig = AsyncInferenceOutputConfig
pOutputConfig_
    }

-- | Configures the behavior of the client used by SageMaker to interact with
-- the model container during asynchronous inference.
asyncInferenceConfig_clientConfig :: Lens.Lens' AsyncInferenceConfig (Prelude.Maybe AsyncInferenceClientConfig)
asyncInferenceConfig_clientConfig :: Lens' AsyncInferenceConfig (Maybe AsyncInferenceClientConfig)
asyncInferenceConfig_clientConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AsyncInferenceConfig' {Maybe AsyncInferenceClientConfig
clientConfig :: Maybe AsyncInferenceClientConfig
$sel:clientConfig:AsyncInferenceConfig' :: AsyncInferenceConfig -> Maybe AsyncInferenceClientConfig
clientConfig} -> Maybe AsyncInferenceClientConfig
clientConfig) (\s :: AsyncInferenceConfig
s@AsyncInferenceConfig' {} Maybe AsyncInferenceClientConfig
a -> AsyncInferenceConfig
s {$sel:clientConfig:AsyncInferenceConfig' :: Maybe AsyncInferenceClientConfig
clientConfig = Maybe AsyncInferenceClientConfig
a} :: AsyncInferenceConfig)

-- | Specifies the configuration for asynchronous inference invocation
-- outputs.
asyncInferenceConfig_outputConfig :: Lens.Lens' AsyncInferenceConfig AsyncInferenceOutputConfig
asyncInferenceConfig_outputConfig :: Lens' AsyncInferenceConfig AsyncInferenceOutputConfig
asyncInferenceConfig_outputConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AsyncInferenceConfig' {AsyncInferenceOutputConfig
outputConfig :: AsyncInferenceOutputConfig
$sel:outputConfig:AsyncInferenceConfig' :: AsyncInferenceConfig -> AsyncInferenceOutputConfig
outputConfig} -> AsyncInferenceOutputConfig
outputConfig) (\s :: AsyncInferenceConfig
s@AsyncInferenceConfig' {} AsyncInferenceOutputConfig
a -> AsyncInferenceConfig
s {$sel:outputConfig:AsyncInferenceConfig' :: AsyncInferenceOutputConfig
outputConfig = AsyncInferenceOutputConfig
a} :: AsyncInferenceConfig)

instance Data.FromJSON AsyncInferenceConfig where
  parseJSON :: Value -> Parser AsyncInferenceConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AsyncInferenceConfig"
      ( \Object
x ->
          Maybe AsyncInferenceClientConfig
-> AsyncInferenceOutputConfig -> AsyncInferenceConfig
AsyncInferenceConfig'
            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
"ClientConfig")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"OutputConfig")
      )

instance Prelude.Hashable AsyncInferenceConfig where
  hashWithSalt :: Int -> AsyncInferenceConfig -> Int
hashWithSalt Int
_salt AsyncInferenceConfig' {Maybe AsyncInferenceClientConfig
AsyncInferenceOutputConfig
outputConfig :: AsyncInferenceOutputConfig
clientConfig :: Maybe AsyncInferenceClientConfig
$sel:outputConfig:AsyncInferenceConfig' :: AsyncInferenceConfig -> AsyncInferenceOutputConfig
$sel:clientConfig:AsyncInferenceConfig' :: AsyncInferenceConfig -> Maybe AsyncInferenceClientConfig
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AsyncInferenceClientConfig
clientConfig
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` AsyncInferenceOutputConfig
outputConfig

instance Prelude.NFData AsyncInferenceConfig where
  rnf :: AsyncInferenceConfig -> ()
rnf AsyncInferenceConfig' {Maybe AsyncInferenceClientConfig
AsyncInferenceOutputConfig
outputConfig :: AsyncInferenceOutputConfig
clientConfig :: Maybe AsyncInferenceClientConfig
$sel:outputConfig:AsyncInferenceConfig' :: AsyncInferenceConfig -> AsyncInferenceOutputConfig
$sel:clientConfig:AsyncInferenceConfig' :: AsyncInferenceConfig -> Maybe AsyncInferenceClientConfig
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe AsyncInferenceClientConfig
clientConfig
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf AsyncInferenceOutputConfig
outputConfig

instance Data.ToJSON AsyncInferenceConfig where
  toJSON :: AsyncInferenceConfig -> Value
toJSON AsyncInferenceConfig' {Maybe AsyncInferenceClientConfig
AsyncInferenceOutputConfig
outputConfig :: AsyncInferenceOutputConfig
clientConfig :: Maybe AsyncInferenceClientConfig
$sel:outputConfig:AsyncInferenceConfig' :: AsyncInferenceConfig -> AsyncInferenceOutputConfig
$sel:clientConfig:AsyncInferenceConfig' :: AsyncInferenceConfig -> Maybe AsyncInferenceClientConfig
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ClientConfig" 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 AsyncInferenceClientConfig
clientConfig,
            forall a. a -> Maybe a
Prelude.Just (Key
"OutputConfig" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= AsyncInferenceOutputConfig
outputConfig)
          ]
      )