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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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'
  { -- | Specifies the configuration for notifications of inference results for
    -- asynchronous inference.
    AsyncInferenceOutputConfig
-> Maybe AsyncInferenceNotificationConfig
notificationConfig :: Prelude.Maybe AsyncInferenceNotificationConfig,
    -- | The Amazon Web Services Key Management Service (Amazon Web Services KMS)
    -- key that Amazon SageMaker uses to encrypt the asynchronous inference
    -- output in Amazon S3.
    AsyncInferenceOutputConfig -> Maybe Text
kmsKeyId :: Prelude.Maybe Prelude.Text,
    -- | The Amazon S3 location to upload inference responses to.
    AsyncInferenceOutputConfig -> Text
s3OutputPath :: Prelude.Text
  }
  deriving (AsyncInferenceOutputConfig -> AsyncInferenceOutputConfig -> Bool
(AsyncInferenceOutputConfig -> AsyncInferenceOutputConfig -> Bool)
-> (AsyncInferenceOutputConfig
    -> AsyncInferenceOutputConfig -> Bool)
-> Eq AsyncInferenceOutputConfig
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]
(Int -> ReadS AsyncInferenceOutputConfig)
-> ReadS [AsyncInferenceOutputConfig]
-> ReadPrec AsyncInferenceOutputConfig
-> ReadPrec [AsyncInferenceOutputConfig]
-> Read 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
(Int -> AsyncInferenceOutputConfig -> ShowS)
-> (AsyncInferenceOutputConfig -> String)
-> ([AsyncInferenceOutputConfig] -> ShowS)
-> Show AsyncInferenceOutputConfig
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.
 AsyncInferenceOutputConfig -> Rep AsyncInferenceOutputConfig x)
-> (forall x.
    Rep AsyncInferenceOutputConfig x -> AsyncInferenceOutputConfig)
-> Generic AsyncInferenceOutputConfig
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:
--
-- 'notificationConfig', 'asyncInferenceOutputConfig_notificationConfig' - Specifies the configuration for notifications of inference results for
-- asynchronous inference.
--
-- 'kmsKeyId', 'asyncInferenceOutputConfig_kmsKeyId' - The Amazon Web Services Key Management Service (Amazon Web Services KMS)
-- key that Amazon SageMaker uses to encrypt the asynchronous inference
-- output in Amazon S3.
--
-- 's3OutputPath', 'asyncInferenceOutputConfig_s3OutputPath' - The Amazon S3 location to upload inference responses to.
newAsyncInferenceOutputConfig ::
  -- | 's3OutputPath'
  Prelude.Text ->
  AsyncInferenceOutputConfig
newAsyncInferenceOutputConfig :: Text -> AsyncInferenceOutputConfig
newAsyncInferenceOutputConfig Text
pS3OutputPath_ =
  AsyncInferenceOutputConfig' :: Maybe AsyncInferenceNotificationConfig
-> Maybe Text -> Text -> AsyncInferenceOutputConfig
AsyncInferenceOutputConfig'
    { $sel:notificationConfig:AsyncInferenceOutputConfig' :: Maybe AsyncInferenceNotificationConfig
notificationConfig =
        Maybe AsyncInferenceNotificationConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:kmsKeyId:AsyncInferenceOutputConfig' :: Maybe Text
kmsKeyId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:s3OutputPath:AsyncInferenceOutputConfig' :: Text
s3OutputPath = Text
pS3OutputPath_
    }

-- | Specifies the configuration for notifications of inference results for
-- asynchronous inference.
asyncInferenceOutputConfig_notificationConfig :: Lens.Lens' AsyncInferenceOutputConfig (Prelude.Maybe AsyncInferenceNotificationConfig)
asyncInferenceOutputConfig_notificationConfig :: (Maybe AsyncInferenceNotificationConfig
 -> f (Maybe AsyncInferenceNotificationConfig))
-> AsyncInferenceOutputConfig -> f AsyncInferenceOutputConfig
asyncInferenceOutputConfig_notificationConfig = (AsyncInferenceOutputConfig
 -> Maybe AsyncInferenceNotificationConfig)
-> (AsyncInferenceOutputConfig
    -> Maybe AsyncInferenceNotificationConfig
    -> AsyncInferenceOutputConfig)
-> Lens
     AsyncInferenceOutputConfig
     AsyncInferenceOutputConfig
     (Maybe AsyncInferenceNotificationConfig)
     (Maybe AsyncInferenceNotificationConfig)
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 Web Services Key Management Service (Amazon Web Services KMS)
-- key that Amazon SageMaker uses to encrypt the asynchronous inference
-- output in Amazon S3.
asyncInferenceOutputConfig_kmsKeyId :: Lens.Lens' AsyncInferenceOutputConfig (Prelude.Maybe Prelude.Text)
asyncInferenceOutputConfig_kmsKeyId :: (Maybe Text -> f (Maybe Text))
-> AsyncInferenceOutputConfig -> f AsyncInferenceOutputConfig
asyncInferenceOutputConfig_kmsKeyId = (AsyncInferenceOutputConfig -> Maybe Text)
-> (AsyncInferenceOutputConfig
    -> Maybe Text -> AsyncInferenceOutputConfig)
-> Lens
     AsyncInferenceOutputConfig
     AsyncInferenceOutputConfig
     (Maybe Text)
     (Maybe Text)
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)

-- | The Amazon S3 location to upload inference responses to.
asyncInferenceOutputConfig_s3OutputPath :: Lens.Lens' AsyncInferenceOutputConfig Prelude.Text
asyncInferenceOutputConfig_s3OutputPath :: (Text -> f Text)
-> AsyncInferenceOutputConfig -> f AsyncInferenceOutputConfig
asyncInferenceOutputConfig_s3OutputPath = (AsyncInferenceOutputConfig -> Text)
-> (AsyncInferenceOutputConfig
    -> Text -> AsyncInferenceOutputConfig)
-> Lens
     AsyncInferenceOutputConfig AsyncInferenceOutputConfig Text Text
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 Core.FromJSON AsyncInferenceOutputConfig where
  parseJSON :: Value -> Parser AsyncInferenceOutputConfig
parseJSON =
    String
-> (Object -> Parser AsyncInferenceOutputConfig)
-> Value
-> Parser AsyncInferenceOutputConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AsyncInferenceOutputConfig"
      ( \Object
x ->
          Maybe AsyncInferenceNotificationConfig
-> Maybe Text -> Text -> AsyncInferenceOutputConfig
AsyncInferenceOutputConfig'
            (Maybe AsyncInferenceNotificationConfig
 -> Maybe Text -> Text -> AsyncInferenceOutputConfig)
-> Parser (Maybe AsyncInferenceNotificationConfig)
-> Parser (Maybe Text -> Text -> AsyncInferenceOutputConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe AsyncInferenceNotificationConfig)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"NotificationConfig")
            Parser (Maybe Text -> Text -> AsyncInferenceOutputConfig)
-> Parser (Maybe Text)
-> Parser (Text -> AsyncInferenceOutputConfig)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"KmsKeyId")
            Parser (Text -> AsyncInferenceOutputConfig)
-> Parser Text -> Parser AsyncInferenceOutputConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"S3OutputPath")
      )

instance Prelude.Hashable AsyncInferenceOutputConfig

instance Prelude.NFData AsyncInferenceOutputConfig

instance Core.ToJSON AsyncInferenceOutputConfig where
  toJSON :: AsyncInferenceOutputConfig -> Value
toJSON AsyncInferenceOutputConfig' {Maybe Text
Maybe AsyncInferenceNotificationConfig
Text
s3OutputPath :: Text
kmsKeyId :: Maybe Text
notificationConfig :: Maybe AsyncInferenceNotificationConfig
$sel:s3OutputPath:AsyncInferenceOutputConfig' :: AsyncInferenceOutputConfig -> Text
$sel:kmsKeyId:AsyncInferenceOutputConfig' :: AsyncInferenceOutputConfig -> Maybe Text
$sel:notificationConfig:AsyncInferenceOutputConfig' :: AsyncInferenceOutputConfig
-> Maybe AsyncInferenceNotificationConfig
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"NotificationConfig" Text -> AsyncInferenceNotificationConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (AsyncInferenceNotificationConfig -> Pair)
-> Maybe AsyncInferenceNotificationConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AsyncInferenceNotificationConfig
notificationConfig,
            (Text
"KmsKeyId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
kmsKeyId,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"S3OutputPath" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
s3OutputPath)
          ]
      )