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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Specifies the configuration for notifications of inference results for
-- asynchronous inference.
--
-- /See:/ 'newAsyncInferenceNotificationConfig' smart constructor.
data AsyncInferenceNotificationConfig = AsyncInferenceNotificationConfig'
  { -- | Amazon SNS topic to post a notification to when inference fails. If no
    -- topic is provided, no notification is sent on failure.
    AsyncInferenceNotificationConfig -> Maybe Text
errorTopic :: Prelude.Maybe Prelude.Text,
    -- | Amazon SNS topic to post a notification to when inference completes
    -- successfully. If no topic is provided, no notification is sent on
    -- success.
    AsyncInferenceNotificationConfig -> Maybe Text
successTopic :: Prelude.Maybe Prelude.Text
  }
  deriving (AsyncInferenceNotificationConfig
-> AsyncInferenceNotificationConfig -> Bool
(AsyncInferenceNotificationConfig
 -> AsyncInferenceNotificationConfig -> Bool)
-> (AsyncInferenceNotificationConfig
    -> AsyncInferenceNotificationConfig -> Bool)
-> Eq AsyncInferenceNotificationConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AsyncInferenceNotificationConfig
-> AsyncInferenceNotificationConfig -> Bool
$c/= :: AsyncInferenceNotificationConfig
-> AsyncInferenceNotificationConfig -> Bool
== :: AsyncInferenceNotificationConfig
-> AsyncInferenceNotificationConfig -> Bool
$c== :: AsyncInferenceNotificationConfig
-> AsyncInferenceNotificationConfig -> Bool
Prelude.Eq, ReadPrec [AsyncInferenceNotificationConfig]
ReadPrec AsyncInferenceNotificationConfig
Int -> ReadS AsyncInferenceNotificationConfig
ReadS [AsyncInferenceNotificationConfig]
(Int -> ReadS AsyncInferenceNotificationConfig)
-> ReadS [AsyncInferenceNotificationConfig]
-> ReadPrec AsyncInferenceNotificationConfig
-> ReadPrec [AsyncInferenceNotificationConfig]
-> Read AsyncInferenceNotificationConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AsyncInferenceNotificationConfig]
$creadListPrec :: ReadPrec [AsyncInferenceNotificationConfig]
readPrec :: ReadPrec AsyncInferenceNotificationConfig
$creadPrec :: ReadPrec AsyncInferenceNotificationConfig
readList :: ReadS [AsyncInferenceNotificationConfig]
$creadList :: ReadS [AsyncInferenceNotificationConfig]
readsPrec :: Int -> ReadS AsyncInferenceNotificationConfig
$creadsPrec :: Int -> ReadS AsyncInferenceNotificationConfig
Prelude.Read, Int -> AsyncInferenceNotificationConfig -> ShowS
[AsyncInferenceNotificationConfig] -> ShowS
AsyncInferenceNotificationConfig -> String
(Int -> AsyncInferenceNotificationConfig -> ShowS)
-> (AsyncInferenceNotificationConfig -> String)
-> ([AsyncInferenceNotificationConfig] -> ShowS)
-> Show AsyncInferenceNotificationConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AsyncInferenceNotificationConfig] -> ShowS
$cshowList :: [AsyncInferenceNotificationConfig] -> ShowS
show :: AsyncInferenceNotificationConfig -> String
$cshow :: AsyncInferenceNotificationConfig -> String
showsPrec :: Int -> AsyncInferenceNotificationConfig -> ShowS
$cshowsPrec :: Int -> AsyncInferenceNotificationConfig -> ShowS
Prelude.Show, (forall x.
 AsyncInferenceNotificationConfig
 -> Rep AsyncInferenceNotificationConfig x)
-> (forall x.
    Rep AsyncInferenceNotificationConfig x
    -> AsyncInferenceNotificationConfig)
-> Generic AsyncInferenceNotificationConfig
forall x.
Rep AsyncInferenceNotificationConfig x
-> AsyncInferenceNotificationConfig
forall x.
AsyncInferenceNotificationConfig
-> Rep AsyncInferenceNotificationConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AsyncInferenceNotificationConfig x
-> AsyncInferenceNotificationConfig
$cfrom :: forall x.
AsyncInferenceNotificationConfig
-> Rep AsyncInferenceNotificationConfig x
Prelude.Generic)

-- |
-- Create a value of 'AsyncInferenceNotificationConfig' 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:
--
-- 'errorTopic', 'asyncInferenceNotificationConfig_errorTopic' - Amazon SNS topic to post a notification to when inference fails. If no
-- topic is provided, no notification is sent on failure.
--
-- 'successTopic', 'asyncInferenceNotificationConfig_successTopic' - Amazon SNS topic to post a notification to when inference completes
-- successfully. If no topic is provided, no notification is sent on
-- success.
newAsyncInferenceNotificationConfig ::
  AsyncInferenceNotificationConfig
newAsyncInferenceNotificationConfig :: AsyncInferenceNotificationConfig
newAsyncInferenceNotificationConfig =
  AsyncInferenceNotificationConfig' :: Maybe Text -> Maybe Text -> AsyncInferenceNotificationConfig
AsyncInferenceNotificationConfig'
    { $sel:errorTopic:AsyncInferenceNotificationConfig' :: Maybe Text
errorTopic =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:successTopic:AsyncInferenceNotificationConfig' :: Maybe Text
successTopic = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Amazon SNS topic to post a notification to when inference fails. If no
-- topic is provided, no notification is sent on failure.
asyncInferenceNotificationConfig_errorTopic :: Lens.Lens' AsyncInferenceNotificationConfig (Prelude.Maybe Prelude.Text)
asyncInferenceNotificationConfig_errorTopic :: (Maybe Text -> f (Maybe Text))
-> AsyncInferenceNotificationConfig
-> f AsyncInferenceNotificationConfig
asyncInferenceNotificationConfig_errorTopic = (AsyncInferenceNotificationConfig -> Maybe Text)
-> (AsyncInferenceNotificationConfig
    -> Maybe Text -> AsyncInferenceNotificationConfig)
-> Lens
     AsyncInferenceNotificationConfig
     AsyncInferenceNotificationConfig
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AsyncInferenceNotificationConfig' {Maybe Text
errorTopic :: Maybe Text
$sel:errorTopic:AsyncInferenceNotificationConfig' :: AsyncInferenceNotificationConfig -> Maybe Text
errorTopic} -> Maybe Text
errorTopic) (\s :: AsyncInferenceNotificationConfig
s@AsyncInferenceNotificationConfig' {} Maybe Text
a -> AsyncInferenceNotificationConfig
s {$sel:errorTopic:AsyncInferenceNotificationConfig' :: Maybe Text
errorTopic = Maybe Text
a} :: AsyncInferenceNotificationConfig)

-- | Amazon SNS topic to post a notification to when inference completes
-- successfully. If no topic is provided, no notification is sent on
-- success.
asyncInferenceNotificationConfig_successTopic :: Lens.Lens' AsyncInferenceNotificationConfig (Prelude.Maybe Prelude.Text)
asyncInferenceNotificationConfig_successTopic :: (Maybe Text -> f (Maybe Text))
-> AsyncInferenceNotificationConfig
-> f AsyncInferenceNotificationConfig
asyncInferenceNotificationConfig_successTopic = (AsyncInferenceNotificationConfig -> Maybe Text)
-> (AsyncInferenceNotificationConfig
    -> Maybe Text -> AsyncInferenceNotificationConfig)
-> Lens
     AsyncInferenceNotificationConfig
     AsyncInferenceNotificationConfig
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AsyncInferenceNotificationConfig' {Maybe Text
successTopic :: Maybe Text
$sel:successTopic:AsyncInferenceNotificationConfig' :: AsyncInferenceNotificationConfig -> Maybe Text
successTopic} -> Maybe Text
successTopic) (\s :: AsyncInferenceNotificationConfig
s@AsyncInferenceNotificationConfig' {} Maybe Text
a -> AsyncInferenceNotificationConfig
s {$sel:successTopic:AsyncInferenceNotificationConfig' :: Maybe Text
successTopic = Maybe Text
a} :: AsyncInferenceNotificationConfig)

instance
  Core.FromJSON
    AsyncInferenceNotificationConfig
  where
  parseJSON :: Value -> Parser AsyncInferenceNotificationConfig
parseJSON =
    String
-> (Object -> Parser AsyncInferenceNotificationConfig)
-> Value
-> Parser AsyncInferenceNotificationConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AsyncInferenceNotificationConfig"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> AsyncInferenceNotificationConfig
AsyncInferenceNotificationConfig'
            (Maybe Text -> Maybe Text -> AsyncInferenceNotificationConfig)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> AsyncInferenceNotificationConfig)
forall (f :: * -> *) a b. Functor 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
"ErrorTopic")
            Parser (Maybe Text -> AsyncInferenceNotificationConfig)
-> Parser (Maybe Text) -> Parser AsyncInferenceNotificationConfig
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
"SuccessTopic")
      )

instance
  Prelude.Hashable
    AsyncInferenceNotificationConfig

instance
  Prelude.NFData
    AsyncInferenceNotificationConfig

instance Core.ToJSON AsyncInferenceNotificationConfig where
  toJSON :: AsyncInferenceNotificationConfig -> Value
toJSON AsyncInferenceNotificationConfig' {Maybe Text
successTopic :: Maybe Text
errorTopic :: Maybe Text
$sel:successTopic:AsyncInferenceNotificationConfig' :: AsyncInferenceNotificationConfig -> Maybe Text
$sel:errorTopic:AsyncInferenceNotificationConfig' :: AsyncInferenceNotificationConfig -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ErrorTopic" 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
errorTopic,
            (Text
"SuccessTopic" 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
successTopic
          ]
      )