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

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

-- | Output configuration information for a labeling job.
--
-- /See:/ 'newLabelingJobOutputConfig' smart constructor.
data LabelingJobOutputConfig = LabelingJobOutputConfig'
  { -- | An Amazon Simple Notification Service (Amazon SNS) output topic ARN.
    -- Provide a @SnsTopicArn@ if you want to do real time chaining to another
    -- streaming job and receive an Amazon SNS notifications each time a data
    -- object is submitted by a worker.
    --
    -- If you provide an @SnsTopicArn@ in @OutputConfig@, when workers complete
    -- labeling tasks, Ground Truth will send labeling task output data to the
    -- SNS output topic you specify here.
    --
    -- To learn more, see
    -- <https://docs.aws.amazon.com/sagemaker/latest/dg/sms-streaming-labeling-job.html#sms-streaming-how-it-works-output-data Receive Output Data from a Streaming Labeling Job>.
    LabelingJobOutputConfig -> Maybe Text
snsTopicArn :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Web Services Key Management Service ID of the key used to
    -- encrypt the output data, if any.
    --
    -- If you provide your own KMS key ID, you must add the required
    -- permissions to your KMS key described in
    -- <https://docs.aws.amazon.com/sagemaker/latest/dg/sms-security-permission.html#sms-security-kms-permissions Encrypt Output Data and Storage Volume with Amazon Web Services KMS>.
    --
    -- If you don\'t provide a KMS key ID, Amazon SageMaker uses the default
    -- Amazon Web Services KMS key for Amazon S3 for your role\'s account to
    -- encrypt your output data.
    --
    -- If you use a bucket policy with an @s3:PutObject@ permission that only
    -- allows objects with server-side encryption, set the condition key of
    -- @s3:x-amz-server-side-encryption@ to @\"aws:kms\"@. For more
    -- information, see
    -- <https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingKMSEncryption.html KMS-Managed Encryption Keys>
    -- in the /Amazon Simple Storage Service Developer Guide./
    LabelingJobOutputConfig -> Maybe Text
kmsKeyId :: Prelude.Maybe Prelude.Text,
    -- | The Amazon S3 location to write output data.
    LabelingJobOutputConfig -> Text
s3OutputPath :: Prelude.Text
  }
  deriving (LabelingJobOutputConfig -> LabelingJobOutputConfig -> Bool
(LabelingJobOutputConfig -> LabelingJobOutputConfig -> Bool)
-> (LabelingJobOutputConfig -> LabelingJobOutputConfig -> Bool)
-> Eq LabelingJobOutputConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LabelingJobOutputConfig -> LabelingJobOutputConfig -> Bool
$c/= :: LabelingJobOutputConfig -> LabelingJobOutputConfig -> Bool
== :: LabelingJobOutputConfig -> LabelingJobOutputConfig -> Bool
$c== :: LabelingJobOutputConfig -> LabelingJobOutputConfig -> Bool
Prelude.Eq, ReadPrec [LabelingJobOutputConfig]
ReadPrec LabelingJobOutputConfig
Int -> ReadS LabelingJobOutputConfig
ReadS [LabelingJobOutputConfig]
(Int -> ReadS LabelingJobOutputConfig)
-> ReadS [LabelingJobOutputConfig]
-> ReadPrec LabelingJobOutputConfig
-> ReadPrec [LabelingJobOutputConfig]
-> Read LabelingJobOutputConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LabelingJobOutputConfig]
$creadListPrec :: ReadPrec [LabelingJobOutputConfig]
readPrec :: ReadPrec LabelingJobOutputConfig
$creadPrec :: ReadPrec LabelingJobOutputConfig
readList :: ReadS [LabelingJobOutputConfig]
$creadList :: ReadS [LabelingJobOutputConfig]
readsPrec :: Int -> ReadS LabelingJobOutputConfig
$creadsPrec :: Int -> ReadS LabelingJobOutputConfig
Prelude.Read, Int -> LabelingJobOutputConfig -> ShowS
[LabelingJobOutputConfig] -> ShowS
LabelingJobOutputConfig -> String
(Int -> LabelingJobOutputConfig -> ShowS)
-> (LabelingJobOutputConfig -> String)
-> ([LabelingJobOutputConfig] -> ShowS)
-> Show LabelingJobOutputConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LabelingJobOutputConfig] -> ShowS
$cshowList :: [LabelingJobOutputConfig] -> ShowS
show :: LabelingJobOutputConfig -> String
$cshow :: LabelingJobOutputConfig -> String
showsPrec :: Int -> LabelingJobOutputConfig -> ShowS
$cshowsPrec :: Int -> LabelingJobOutputConfig -> ShowS
Prelude.Show, (forall x.
 LabelingJobOutputConfig -> Rep LabelingJobOutputConfig x)
-> (forall x.
    Rep LabelingJobOutputConfig x -> LabelingJobOutputConfig)
-> Generic LabelingJobOutputConfig
forall x. Rep LabelingJobOutputConfig x -> LabelingJobOutputConfig
forall x. LabelingJobOutputConfig -> Rep LabelingJobOutputConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LabelingJobOutputConfig x -> LabelingJobOutputConfig
$cfrom :: forall x. LabelingJobOutputConfig -> Rep LabelingJobOutputConfig x
Prelude.Generic)

-- |
-- Create a value of 'LabelingJobOutputConfig' 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:
--
-- 'snsTopicArn', 'labelingJobOutputConfig_snsTopicArn' - An Amazon Simple Notification Service (Amazon SNS) output topic ARN.
-- Provide a @SnsTopicArn@ if you want to do real time chaining to another
-- streaming job and receive an Amazon SNS notifications each time a data
-- object is submitted by a worker.
--
-- If you provide an @SnsTopicArn@ in @OutputConfig@, when workers complete
-- labeling tasks, Ground Truth will send labeling task output data to the
-- SNS output topic you specify here.
--
-- To learn more, see
-- <https://docs.aws.amazon.com/sagemaker/latest/dg/sms-streaming-labeling-job.html#sms-streaming-how-it-works-output-data Receive Output Data from a Streaming Labeling Job>.
--
-- 'kmsKeyId', 'labelingJobOutputConfig_kmsKeyId' - The Amazon Web Services Key Management Service ID of the key used to
-- encrypt the output data, if any.
--
-- If you provide your own KMS key ID, you must add the required
-- permissions to your KMS key described in
-- <https://docs.aws.amazon.com/sagemaker/latest/dg/sms-security-permission.html#sms-security-kms-permissions Encrypt Output Data and Storage Volume with Amazon Web Services KMS>.
--
-- If you don\'t provide a KMS key ID, Amazon SageMaker uses the default
-- Amazon Web Services KMS key for Amazon S3 for your role\'s account to
-- encrypt your output data.
--
-- If you use a bucket policy with an @s3:PutObject@ permission that only
-- allows objects with server-side encryption, set the condition key of
-- @s3:x-amz-server-side-encryption@ to @\"aws:kms\"@. For more
-- information, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingKMSEncryption.html KMS-Managed Encryption Keys>
-- in the /Amazon Simple Storage Service Developer Guide./
--
-- 's3OutputPath', 'labelingJobOutputConfig_s3OutputPath' - The Amazon S3 location to write output data.
newLabelingJobOutputConfig ::
  -- | 's3OutputPath'
  Prelude.Text ->
  LabelingJobOutputConfig
newLabelingJobOutputConfig :: Text -> LabelingJobOutputConfig
newLabelingJobOutputConfig Text
pS3OutputPath_ =
  LabelingJobOutputConfig' :: Maybe Text -> Maybe Text -> Text -> LabelingJobOutputConfig
LabelingJobOutputConfig'
    { $sel:snsTopicArn:LabelingJobOutputConfig' :: Maybe Text
snsTopicArn =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:kmsKeyId:LabelingJobOutputConfig' :: Maybe Text
kmsKeyId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:s3OutputPath:LabelingJobOutputConfig' :: Text
s3OutputPath = Text
pS3OutputPath_
    }

-- | An Amazon Simple Notification Service (Amazon SNS) output topic ARN.
-- Provide a @SnsTopicArn@ if you want to do real time chaining to another
-- streaming job and receive an Amazon SNS notifications each time a data
-- object is submitted by a worker.
--
-- If you provide an @SnsTopicArn@ in @OutputConfig@, when workers complete
-- labeling tasks, Ground Truth will send labeling task output data to the
-- SNS output topic you specify here.
--
-- To learn more, see
-- <https://docs.aws.amazon.com/sagemaker/latest/dg/sms-streaming-labeling-job.html#sms-streaming-how-it-works-output-data Receive Output Data from a Streaming Labeling Job>.
labelingJobOutputConfig_snsTopicArn :: Lens.Lens' LabelingJobOutputConfig (Prelude.Maybe Prelude.Text)
labelingJobOutputConfig_snsTopicArn :: (Maybe Text -> f (Maybe Text))
-> LabelingJobOutputConfig -> f LabelingJobOutputConfig
labelingJobOutputConfig_snsTopicArn = (LabelingJobOutputConfig -> Maybe Text)
-> (LabelingJobOutputConfig
    -> Maybe Text -> LabelingJobOutputConfig)
-> Lens
     LabelingJobOutputConfig
     LabelingJobOutputConfig
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LabelingJobOutputConfig' {Maybe Text
snsTopicArn :: Maybe Text
$sel:snsTopicArn:LabelingJobOutputConfig' :: LabelingJobOutputConfig -> Maybe Text
snsTopicArn} -> Maybe Text
snsTopicArn) (\s :: LabelingJobOutputConfig
s@LabelingJobOutputConfig' {} Maybe Text
a -> LabelingJobOutputConfig
s {$sel:snsTopicArn:LabelingJobOutputConfig' :: Maybe Text
snsTopicArn = Maybe Text
a} :: LabelingJobOutputConfig)

-- | The Amazon Web Services Key Management Service ID of the key used to
-- encrypt the output data, if any.
--
-- If you provide your own KMS key ID, you must add the required
-- permissions to your KMS key described in
-- <https://docs.aws.amazon.com/sagemaker/latest/dg/sms-security-permission.html#sms-security-kms-permissions Encrypt Output Data and Storage Volume with Amazon Web Services KMS>.
--
-- If you don\'t provide a KMS key ID, Amazon SageMaker uses the default
-- Amazon Web Services KMS key for Amazon S3 for your role\'s account to
-- encrypt your output data.
--
-- If you use a bucket policy with an @s3:PutObject@ permission that only
-- allows objects with server-side encryption, set the condition key of
-- @s3:x-amz-server-side-encryption@ to @\"aws:kms\"@. For more
-- information, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingKMSEncryption.html KMS-Managed Encryption Keys>
-- in the /Amazon Simple Storage Service Developer Guide./
labelingJobOutputConfig_kmsKeyId :: Lens.Lens' LabelingJobOutputConfig (Prelude.Maybe Prelude.Text)
labelingJobOutputConfig_kmsKeyId :: (Maybe Text -> f (Maybe Text))
-> LabelingJobOutputConfig -> f LabelingJobOutputConfig
labelingJobOutputConfig_kmsKeyId = (LabelingJobOutputConfig -> Maybe Text)
-> (LabelingJobOutputConfig
    -> Maybe Text -> LabelingJobOutputConfig)
-> Lens
     LabelingJobOutputConfig
     LabelingJobOutputConfig
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LabelingJobOutputConfig' {Maybe Text
kmsKeyId :: Maybe Text
$sel:kmsKeyId:LabelingJobOutputConfig' :: LabelingJobOutputConfig -> Maybe Text
kmsKeyId} -> Maybe Text
kmsKeyId) (\s :: LabelingJobOutputConfig
s@LabelingJobOutputConfig' {} Maybe Text
a -> LabelingJobOutputConfig
s {$sel:kmsKeyId:LabelingJobOutputConfig' :: Maybe Text
kmsKeyId = Maybe Text
a} :: LabelingJobOutputConfig)

-- | The Amazon S3 location to write output data.
labelingJobOutputConfig_s3OutputPath :: Lens.Lens' LabelingJobOutputConfig Prelude.Text
labelingJobOutputConfig_s3OutputPath :: (Text -> f Text)
-> LabelingJobOutputConfig -> f LabelingJobOutputConfig
labelingJobOutputConfig_s3OutputPath = (LabelingJobOutputConfig -> Text)
-> (LabelingJobOutputConfig -> Text -> LabelingJobOutputConfig)
-> Lens LabelingJobOutputConfig LabelingJobOutputConfig Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LabelingJobOutputConfig' {Text
s3OutputPath :: Text
$sel:s3OutputPath:LabelingJobOutputConfig' :: LabelingJobOutputConfig -> Text
s3OutputPath} -> Text
s3OutputPath) (\s :: LabelingJobOutputConfig
s@LabelingJobOutputConfig' {} Text
a -> LabelingJobOutputConfig
s {$sel:s3OutputPath:LabelingJobOutputConfig' :: Text
s3OutputPath = Text
a} :: LabelingJobOutputConfig)

instance Core.FromJSON LabelingJobOutputConfig where
  parseJSON :: Value -> Parser LabelingJobOutputConfig
parseJSON =
    String
-> (Object -> Parser LabelingJobOutputConfig)
-> Value
-> Parser LabelingJobOutputConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"LabelingJobOutputConfig"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Text -> LabelingJobOutputConfig
LabelingJobOutputConfig'
            (Maybe Text -> Maybe Text -> Text -> LabelingJobOutputConfig)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Text -> LabelingJobOutputConfig)
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
"SnsTopicArn")
            Parser (Maybe Text -> Text -> LabelingJobOutputConfig)
-> Parser (Maybe Text) -> Parser (Text -> LabelingJobOutputConfig)
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 -> LabelingJobOutputConfig)
-> Parser Text -> Parser LabelingJobOutputConfig
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 LabelingJobOutputConfig

instance Prelude.NFData LabelingJobOutputConfig

instance Core.ToJSON LabelingJobOutputConfig where
  toJSON :: LabelingJobOutputConfig -> Value
toJSON LabelingJobOutputConfig' {Maybe Text
Text
s3OutputPath :: Text
kmsKeyId :: Maybe Text
snsTopicArn :: Maybe Text
$sel:s3OutputPath:LabelingJobOutputConfig' :: LabelingJobOutputConfig -> Text
$sel:kmsKeyId:LabelingJobOutputConfig' :: LabelingJobOutputConfig -> Maybe Text
$sel:snsTopicArn:LabelingJobOutputConfig' :: LabelingJobOutputConfig -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"SnsTopicArn" 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
snsTopicArn,
            (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)
          ]
      )