{-# 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.AsyncInferenceOutputConfig
-- 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.AsyncInferenceOutputConfig 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.AsyncInferenceNotificationConfig

-- | Specifies the configuration for asynchronous inference invocation
-- outputs.
--
-- /See:/ 'newAsyncInferenceOutputConfig' smart constructor.
data AsyncInferenceOutputConfig = AsyncInferenceOutputConfig'
  { -- | The Amazon Web Services Key Management Service (Amazon Web Services KMS)
    -- key that SageMaker uses to encrypt the asynchronous inference output in
    -- Amazon S3.
    AsyncInferenceOutputConfig -> Maybe Text
kmsKeyId :: Prelude.Maybe Prelude.Text,
    -- | Specifies the configuration for notifications of inference results for
    -- asynchronous inference.
    AsyncInferenceOutputConfig
-> Maybe AsyncInferenceNotificationConfig
notificationConfig :: Prelude.Maybe AsyncInferenceNotificationConfig,
    -- | The Amazon S3 location to upload inference responses to.
    AsyncInferenceOutputConfig -> Text
s3OutputPath :: Prelude.Text
  }
  deriving (AsyncInferenceOutputConfig -> AsyncInferenceOutputConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AsyncInferenceOutputConfig -> AsyncInferenceOutputConfig -> Bool
$c/= :: AsyncInferenceOutputConfig -> AsyncInferenceOutputConfig -> Bool
== :: AsyncInferenceOutputConfig -> AsyncInferenceOutputConfig -> Bool
$c== :: AsyncInferenceOutputConfig -> AsyncInferenceOutputConfig -> Bool
Prelude.Eq, ReadPrec [AsyncInferenceOutputConfig]
ReadPrec AsyncInferenceOutputConfig
Int -> ReadS AsyncInferenceOutputConfig
ReadS [AsyncInferenceOutputConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AsyncInferenceOutputConfig]
$creadListPrec :: ReadPrec [AsyncInferenceOutputConfig]
readPrec :: ReadPrec AsyncInferenceOutputConfig
$creadPrec :: ReadPrec AsyncInferenceOutputConfig
readList :: ReadS [AsyncInferenceOutputConfig]
$creadList :: ReadS [AsyncInferenceOutputConfig]
readsPrec :: Int -> ReadS AsyncInferenceOutputConfig
$creadsPrec :: Int -> ReadS AsyncInferenceOutputConfig
Prelude.Read, Int -> AsyncInferenceOutputConfig -> ShowS
[AsyncInferenceOutputConfig] -> ShowS
AsyncInferenceOutputConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AsyncInferenceOutputConfig] -> ShowS
$cshowList :: [AsyncInferenceOutputConfig] -> ShowS
show :: AsyncInferenceOutputConfig -> String
$cshow :: AsyncInferenceOutputConfig -> String
showsPrec :: Int -> AsyncInferenceOutputConfig -> ShowS
$cshowsPrec :: Int -> AsyncInferenceOutputConfig -> ShowS
Prelude.Show, forall x.
Rep AsyncInferenceOutputConfig x -> AsyncInferenceOutputConfig
forall x.
AsyncInferenceOutputConfig -> Rep AsyncInferenceOutputConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AsyncInferenceOutputConfig x -> AsyncInferenceOutputConfig
$cfrom :: forall x.
AsyncInferenceOutputConfig -> Rep AsyncInferenceOutputConfig x
Prelude.Generic)

-- |
-- Create a value of 'AsyncInferenceOutputConfig' 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:
--
-- 'kmsKeyId', 'asyncInferenceOutputConfig_kmsKeyId' - The Amazon Web Services Key Management Service (Amazon Web Services KMS)
-- key that SageMaker uses to encrypt the asynchronous inference output in
-- Amazon S3.
--
-- 'notificationConfig', 'asyncInferenceOutputConfig_notificationConfig' - Specifies the configuration for notifications of inference results for
-- asynchronous inference.
--
-- 's3OutputPath', 'asyncInferenceOutputConfig_s3OutputPath' - The Amazon S3 location to upload inference responses to.
newAsyncInferenceOutputConfig ::
  -- | 's3OutputPath'
  Prelude.Text ->
  AsyncInferenceOutputConfig
newAsyncInferenceOutputConfig :: Text -> AsyncInferenceOutputConfig
newAsyncInferenceOutputConfig Text
pS3OutputPath_ =
  AsyncInferenceOutputConfig'
    { $sel:kmsKeyId:AsyncInferenceOutputConfig' :: Maybe Text
kmsKeyId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:notificationConfig:AsyncInferenceOutputConfig' :: Maybe AsyncInferenceNotificationConfig
notificationConfig = forall a. Maybe a
Prelude.Nothing,
      $sel:s3OutputPath:AsyncInferenceOutputConfig' :: Text
s3OutputPath = Text
pS3OutputPath_
    }

-- | The Amazon Web Services Key Management Service (Amazon Web Services KMS)
-- key that SageMaker uses to encrypt the asynchronous inference output in
-- Amazon S3.
asyncInferenceOutputConfig_kmsKeyId :: Lens.Lens' AsyncInferenceOutputConfig (Prelude.Maybe Prelude.Text)
asyncInferenceOutputConfig_kmsKeyId :: Lens' AsyncInferenceOutputConfig (Maybe Text)
asyncInferenceOutputConfig_kmsKeyId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AsyncInferenceOutputConfig' {Maybe Text
kmsKeyId :: Maybe Text
$sel:kmsKeyId:AsyncInferenceOutputConfig' :: AsyncInferenceOutputConfig -> Maybe Text
kmsKeyId} -> Maybe Text
kmsKeyId) (\s :: AsyncInferenceOutputConfig
s@AsyncInferenceOutputConfig' {} Maybe Text
a -> AsyncInferenceOutputConfig
s {$sel:kmsKeyId:AsyncInferenceOutputConfig' :: Maybe Text
kmsKeyId = Maybe Text
a} :: AsyncInferenceOutputConfig)

-- | Specifies the configuration for notifications of inference results for
-- asynchronous inference.
asyncInferenceOutputConfig_notificationConfig :: Lens.Lens' AsyncInferenceOutputConfig (Prelude.Maybe AsyncInferenceNotificationConfig)
asyncInferenceOutputConfig_notificationConfig :: Lens'
  AsyncInferenceOutputConfig (Maybe AsyncInferenceNotificationConfig)
asyncInferenceOutputConfig_notificationConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AsyncInferenceOutputConfig' {Maybe AsyncInferenceNotificationConfig
notificationConfig :: Maybe AsyncInferenceNotificationConfig
$sel:notificationConfig:AsyncInferenceOutputConfig' :: AsyncInferenceOutputConfig
-> Maybe AsyncInferenceNotificationConfig
notificationConfig} -> Maybe AsyncInferenceNotificationConfig
notificationConfig) (\s :: AsyncInferenceOutputConfig
s@AsyncInferenceOutputConfig' {} Maybe AsyncInferenceNotificationConfig
a -> AsyncInferenceOutputConfig
s {$sel:notificationConfig:AsyncInferenceOutputConfig' :: Maybe AsyncInferenceNotificationConfig
notificationConfig = Maybe AsyncInferenceNotificationConfig
a} :: AsyncInferenceOutputConfig)

-- | The Amazon S3 location to upload inference responses to.
asyncInferenceOutputConfig_s3OutputPath :: Lens.Lens' AsyncInferenceOutputConfig Prelude.Text
asyncInferenceOutputConfig_s3OutputPath :: Lens' AsyncInferenceOutputConfig Text
asyncInferenceOutputConfig_s3OutputPath = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AsyncInferenceOutputConfig' {Text
s3OutputPath :: Text
$sel:s3OutputPath:AsyncInferenceOutputConfig' :: AsyncInferenceOutputConfig -> Text
s3OutputPath} -> Text
s3OutputPath) (\s :: AsyncInferenceOutputConfig
s@AsyncInferenceOutputConfig' {} Text
a -> AsyncInferenceOutputConfig
s {$sel:s3OutputPath:AsyncInferenceOutputConfig' :: Text
s3OutputPath = Text
a} :: AsyncInferenceOutputConfig)

instance Data.FromJSON AsyncInferenceOutputConfig where
  parseJSON :: Value -> Parser AsyncInferenceOutputConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AsyncInferenceOutputConfig"
      ( \Object
x ->
          Maybe Text
-> Maybe AsyncInferenceNotificationConfig
-> Text
-> AsyncInferenceOutputConfig
AsyncInferenceOutputConfig'
            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
"KmsKeyId")
            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
"NotificationConfig")
            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
"S3OutputPath")
      )

instance Prelude.Hashable AsyncInferenceOutputConfig where
  hashWithSalt :: Int -> AsyncInferenceOutputConfig -> Int
hashWithSalt Int
_salt AsyncInferenceOutputConfig' {Maybe Text
Maybe AsyncInferenceNotificationConfig
Text
s3OutputPath :: Text
notificationConfig :: Maybe AsyncInferenceNotificationConfig
kmsKeyId :: Maybe Text
$sel:s3OutputPath:AsyncInferenceOutputConfig' :: AsyncInferenceOutputConfig -> Text
$sel:notificationConfig:AsyncInferenceOutputConfig' :: AsyncInferenceOutputConfig
-> Maybe AsyncInferenceNotificationConfig
$sel:kmsKeyId:AsyncInferenceOutputConfig' :: AsyncInferenceOutputConfig -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
kmsKeyId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AsyncInferenceNotificationConfig
notificationConfig
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
s3OutputPath

instance Prelude.NFData AsyncInferenceOutputConfig where
  rnf :: AsyncInferenceOutputConfig -> ()
rnf AsyncInferenceOutputConfig' {Maybe Text
Maybe AsyncInferenceNotificationConfig
Text
s3OutputPath :: Text
notificationConfig :: Maybe AsyncInferenceNotificationConfig
kmsKeyId :: Maybe Text
$sel:s3OutputPath:AsyncInferenceOutputConfig' :: AsyncInferenceOutputConfig -> Text
$sel:notificationConfig:AsyncInferenceOutputConfig' :: AsyncInferenceOutputConfig
-> Maybe AsyncInferenceNotificationConfig
$sel:kmsKeyId:AsyncInferenceOutputConfig' :: AsyncInferenceOutputConfig -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
kmsKeyId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe AsyncInferenceNotificationConfig
notificationConfig
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
s3OutputPath

instance Data.ToJSON AsyncInferenceOutputConfig where
  toJSON :: AsyncInferenceOutputConfig -> Value
toJSON AsyncInferenceOutputConfig' {Maybe Text
Maybe AsyncInferenceNotificationConfig
Text
s3OutputPath :: Text
notificationConfig :: Maybe AsyncInferenceNotificationConfig
kmsKeyId :: Maybe Text
$sel:s3OutputPath:AsyncInferenceOutputConfig' :: AsyncInferenceOutputConfig -> Text
$sel:notificationConfig:AsyncInferenceOutputConfig' :: AsyncInferenceOutputConfig
-> Maybe AsyncInferenceNotificationConfig
$sel:kmsKeyId:AsyncInferenceOutputConfig' :: AsyncInferenceOutputConfig -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"KmsKeyId" 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 Text
kmsKeyId,
            (Key
"NotificationConfig" 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 AsyncInferenceNotificationConfig
notificationConfig,
            forall a. a -> Maybe a
Prelude.Just (Key
"S3OutputPath" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
s3OutputPath)
          ]
      )