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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 Amazon 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
(AsyncInferenceConfig -> AsyncInferenceConfig -> Bool)
-> (AsyncInferenceConfig -> AsyncInferenceConfig -> Bool)
-> Eq AsyncInferenceConfig
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]
(Int -> ReadS AsyncInferenceConfig)
-> ReadS [AsyncInferenceConfig]
-> ReadPrec AsyncInferenceConfig
-> ReadPrec [AsyncInferenceConfig]
-> Read 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
(Int -> AsyncInferenceConfig -> ShowS)
-> (AsyncInferenceConfig -> String)
-> ([AsyncInferenceConfig] -> ShowS)
-> Show AsyncInferenceConfig
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. AsyncInferenceConfig -> Rep AsyncInferenceConfig x)
-> (forall x. Rep AsyncInferenceConfig x -> AsyncInferenceConfig)
-> Generic AsyncInferenceConfig
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 Amazon 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' :: Maybe AsyncInferenceClientConfig
-> AsyncInferenceOutputConfig -> AsyncInferenceConfig
AsyncInferenceConfig'
    { $sel:clientConfig:AsyncInferenceConfig' :: Maybe AsyncInferenceClientConfig
clientConfig =
        Maybe AsyncInferenceClientConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:outputConfig:AsyncInferenceConfig' :: AsyncInferenceOutputConfig
outputConfig = AsyncInferenceOutputConfig
pOutputConfig_
    }

-- | Configures the behavior of the client used by Amazon SageMaker to
-- interact with the model container during asynchronous inference.
asyncInferenceConfig_clientConfig :: Lens.Lens' AsyncInferenceConfig (Prelude.Maybe AsyncInferenceClientConfig)
asyncInferenceConfig_clientConfig :: (Maybe AsyncInferenceClientConfig
 -> f (Maybe AsyncInferenceClientConfig))
-> AsyncInferenceConfig -> f AsyncInferenceConfig
asyncInferenceConfig_clientConfig = (AsyncInferenceConfig -> Maybe AsyncInferenceClientConfig)
-> (AsyncInferenceConfig
    -> Maybe AsyncInferenceClientConfig -> AsyncInferenceConfig)
-> Lens
     AsyncInferenceConfig
     AsyncInferenceConfig
     (Maybe AsyncInferenceClientConfig)
     (Maybe AsyncInferenceClientConfig)
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 :: (AsyncInferenceOutputConfig -> f AsyncInferenceOutputConfig)
-> AsyncInferenceConfig -> f AsyncInferenceConfig
asyncInferenceConfig_outputConfig = (AsyncInferenceConfig -> AsyncInferenceOutputConfig)
-> (AsyncInferenceConfig
    -> AsyncInferenceOutputConfig -> AsyncInferenceConfig)
-> Lens
     AsyncInferenceConfig
     AsyncInferenceConfig
     AsyncInferenceOutputConfig
     AsyncInferenceOutputConfig
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 Core.FromJSON AsyncInferenceConfig where
  parseJSON :: Value -> Parser AsyncInferenceConfig
parseJSON =
    String
-> (Object -> Parser AsyncInferenceConfig)
-> Value
-> Parser AsyncInferenceConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AsyncInferenceConfig"
      ( \Object
x ->
          Maybe AsyncInferenceClientConfig
-> AsyncInferenceOutputConfig -> AsyncInferenceConfig
AsyncInferenceConfig'
            (Maybe AsyncInferenceClientConfig
 -> AsyncInferenceOutputConfig -> AsyncInferenceConfig)
-> Parser (Maybe AsyncInferenceClientConfig)
-> Parser (AsyncInferenceOutputConfig -> AsyncInferenceConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe AsyncInferenceClientConfig)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ClientConfig")
            Parser (AsyncInferenceOutputConfig -> AsyncInferenceConfig)
-> Parser AsyncInferenceOutputConfig -> Parser AsyncInferenceConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser AsyncInferenceOutputConfig
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"OutputConfig")
      )

instance Prelude.Hashable AsyncInferenceConfig

instance Prelude.NFData AsyncInferenceConfig

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ClientConfig" Text -> AsyncInferenceClientConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (AsyncInferenceClientConfig -> Pair)
-> Maybe AsyncInferenceClientConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AsyncInferenceClientConfig
clientConfig,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"OutputConfig" Text -> AsyncInferenceOutputConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= AsyncInferenceOutputConfig
outputConfig)
          ]
      )