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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SageMaker.Types.LabelingJobS3DataSource
import Amazonka.SageMaker.Types.LabelingJobSnsDataSource

-- | Provides information about the location of input data.
--
-- You must specify at least one of the following: @S3DataSource@ or
-- @SnsDataSource@.
--
-- Use @SnsDataSource@ to specify an SNS input topic for a streaming
-- labeling job. If you do not specify and SNS input topic ARN, Ground
-- Truth will create a one-time labeling job.
--
-- Use @S3DataSource@ to specify an input manifest file for both streaming
-- and one-time labeling jobs. Adding an @S3DataSource@ is optional if you
-- use @SnsDataSource@ to create a streaming labeling job.
--
-- /See:/ 'newLabelingJobDataSource' smart constructor.
data LabelingJobDataSource = LabelingJobDataSource'
  { -- | The Amazon S3 location of the input data objects.
    LabelingJobDataSource -> Maybe LabelingJobS3DataSource
s3DataSource :: Prelude.Maybe LabelingJobS3DataSource,
    -- | An Amazon SNS data source used for streaming labeling jobs. To learn
    -- more, see
    -- <https://docs.aws.amazon.com/sagemaker/latest/dg/sms-streaming-labeling-job.html#sms-streaming-how-it-works-send-data Send Data to a Streaming Labeling Job>.
    LabelingJobDataSource -> Maybe LabelingJobSnsDataSource
snsDataSource :: Prelude.Maybe LabelingJobSnsDataSource
  }
  deriving (LabelingJobDataSource -> LabelingJobDataSource -> Bool
(LabelingJobDataSource -> LabelingJobDataSource -> Bool)
-> (LabelingJobDataSource -> LabelingJobDataSource -> Bool)
-> Eq LabelingJobDataSource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LabelingJobDataSource -> LabelingJobDataSource -> Bool
$c/= :: LabelingJobDataSource -> LabelingJobDataSource -> Bool
== :: LabelingJobDataSource -> LabelingJobDataSource -> Bool
$c== :: LabelingJobDataSource -> LabelingJobDataSource -> Bool
Prelude.Eq, ReadPrec [LabelingJobDataSource]
ReadPrec LabelingJobDataSource
Int -> ReadS LabelingJobDataSource
ReadS [LabelingJobDataSource]
(Int -> ReadS LabelingJobDataSource)
-> ReadS [LabelingJobDataSource]
-> ReadPrec LabelingJobDataSource
-> ReadPrec [LabelingJobDataSource]
-> Read LabelingJobDataSource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LabelingJobDataSource]
$creadListPrec :: ReadPrec [LabelingJobDataSource]
readPrec :: ReadPrec LabelingJobDataSource
$creadPrec :: ReadPrec LabelingJobDataSource
readList :: ReadS [LabelingJobDataSource]
$creadList :: ReadS [LabelingJobDataSource]
readsPrec :: Int -> ReadS LabelingJobDataSource
$creadsPrec :: Int -> ReadS LabelingJobDataSource
Prelude.Read, Int -> LabelingJobDataSource -> ShowS
[LabelingJobDataSource] -> ShowS
LabelingJobDataSource -> String
(Int -> LabelingJobDataSource -> ShowS)
-> (LabelingJobDataSource -> String)
-> ([LabelingJobDataSource] -> ShowS)
-> Show LabelingJobDataSource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LabelingJobDataSource] -> ShowS
$cshowList :: [LabelingJobDataSource] -> ShowS
show :: LabelingJobDataSource -> String
$cshow :: LabelingJobDataSource -> String
showsPrec :: Int -> LabelingJobDataSource -> ShowS
$cshowsPrec :: Int -> LabelingJobDataSource -> ShowS
Prelude.Show, (forall x. LabelingJobDataSource -> Rep LabelingJobDataSource x)
-> (forall x. Rep LabelingJobDataSource x -> LabelingJobDataSource)
-> Generic LabelingJobDataSource
forall x. Rep LabelingJobDataSource x -> LabelingJobDataSource
forall x. LabelingJobDataSource -> Rep LabelingJobDataSource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LabelingJobDataSource x -> LabelingJobDataSource
$cfrom :: forall x. LabelingJobDataSource -> Rep LabelingJobDataSource x
Prelude.Generic)

-- |
-- Create a value of 'LabelingJobDataSource' 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:
--
-- 's3DataSource', 'labelingJobDataSource_s3DataSource' - The Amazon S3 location of the input data objects.
--
-- 'snsDataSource', 'labelingJobDataSource_snsDataSource' - An Amazon SNS data source used for streaming labeling jobs. To learn
-- more, see
-- <https://docs.aws.amazon.com/sagemaker/latest/dg/sms-streaming-labeling-job.html#sms-streaming-how-it-works-send-data Send Data to a Streaming Labeling Job>.
newLabelingJobDataSource ::
  LabelingJobDataSource
newLabelingJobDataSource :: LabelingJobDataSource
newLabelingJobDataSource =
  LabelingJobDataSource' :: Maybe LabelingJobS3DataSource
-> Maybe LabelingJobSnsDataSource -> LabelingJobDataSource
LabelingJobDataSource'
    { $sel:s3DataSource:LabelingJobDataSource' :: Maybe LabelingJobS3DataSource
s3DataSource =
        Maybe LabelingJobS3DataSource
forall a. Maybe a
Prelude.Nothing,
      $sel:snsDataSource:LabelingJobDataSource' :: Maybe LabelingJobSnsDataSource
snsDataSource = Maybe LabelingJobSnsDataSource
forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon S3 location of the input data objects.
labelingJobDataSource_s3DataSource :: Lens.Lens' LabelingJobDataSource (Prelude.Maybe LabelingJobS3DataSource)
labelingJobDataSource_s3DataSource :: (Maybe LabelingJobS3DataSource
 -> f (Maybe LabelingJobS3DataSource))
-> LabelingJobDataSource -> f LabelingJobDataSource
labelingJobDataSource_s3DataSource = (LabelingJobDataSource -> Maybe LabelingJobS3DataSource)
-> (LabelingJobDataSource
    -> Maybe LabelingJobS3DataSource -> LabelingJobDataSource)
-> Lens
     LabelingJobDataSource
     LabelingJobDataSource
     (Maybe LabelingJobS3DataSource)
     (Maybe LabelingJobS3DataSource)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LabelingJobDataSource' {Maybe LabelingJobS3DataSource
s3DataSource :: Maybe LabelingJobS3DataSource
$sel:s3DataSource:LabelingJobDataSource' :: LabelingJobDataSource -> Maybe LabelingJobS3DataSource
s3DataSource} -> Maybe LabelingJobS3DataSource
s3DataSource) (\s :: LabelingJobDataSource
s@LabelingJobDataSource' {} Maybe LabelingJobS3DataSource
a -> LabelingJobDataSource
s {$sel:s3DataSource:LabelingJobDataSource' :: Maybe LabelingJobS3DataSource
s3DataSource = Maybe LabelingJobS3DataSource
a} :: LabelingJobDataSource)

-- | An Amazon SNS data source used for streaming labeling jobs. To learn
-- more, see
-- <https://docs.aws.amazon.com/sagemaker/latest/dg/sms-streaming-labeling-job.html#sms-streaming-how-it-works-send-data Send Data to a Streaming Labeling Job>.
labelingJobDataSource_snsDataSource :: Lens.Lens' LabelingJobDataSource (Prelude.Maybe LabelingJobSnsDataSource)
labelingJobDataSource_snsDataSource :: (Maybe LabelingJobSnsDataSource
 -> f (Maybe LabelingJobSnsDataSource))
-> LabelingJobDataSource -> f LabelingJobDataSource
labelingJobDataSource_snsDataSource = (LabelingJobDataSource -> Maybe LabelingJobSnsDataSource)
-> (LabelingJobDataSource
    -> Maybe LabelingJobSnsDataSource -> LabelingJobDataSource)
-> Lens
     LabelingJobDataSource
     LabelingJobDataSource
     (Maybe LabelingJobSnsDataSource)
     (Maybe LabelingJobSnsDataSource)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LabelingJobDataSource' {Maybe LabelingJobSnsDataSource
snsDataSource :: Maybe LabelingJobSnsDataSource
$sel:snsDataSource:LabelingJobDataSource' :: LabelingJobDataSource -> Maybe LabelingJobSnsDataSource
snsDataSource} -> Maybe LabelingJobSnsDataSource
snsDataSource) (\s :: LabelingJobDataSource
s@LabelingJobDataSource' {} Maybe LabelingJobSnsDataSource
a -> LabelingJobDataSource
s {$sel:snsDataSource:LabelingJobDataSource' :: Maybe LabelingJobSnsDataSource
snsDataSource = Maybe LabelingJobSnsDataSource
a} :: LabelingJobDataSource)

instance Core.FromJSON LabelingJobDataSource where
  parseJSON :: Value -> Parser LabelingJobDataSource
parseJSON =
    String
-> (Object -> Parser LabelingJobDataSource)
-> Value
-> Parser LabelingJobDataSource
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"LabelingJobDataSource"
      ( \Object
x ->
          Maybe LabelingJobS3DataSource
-> Maybe LabelingJobSnsDataSource -> LabelingJobDataSource
LabelingJobDataSource'
            (Maybe LabelingJobS3DataSource
 -> Maybe LabelingJobSnsDataSource -> LabelingJobDataSource)
-> Parser (Maybe LabelingJobS3DataSource)
-> Parser (Maybe LabelingJobSnsDataSource -> LabelingJobDataSource)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe LabelingJobS3DataSource)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"S3DataSource")
            Parser (Maybe LabelingJobSnsDataSource -> LabelingJobDataSource)
-> Parser (Maybe LabelingJobSnsDataSource)
-> Parser LabelingJobDataSource
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe LabelingJobSnsDataSource)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SnsDataSource")
      )

instance Prelude.Hashable LabelingJobDataSource

instance Prelude.NFData LabelingJobDataSource

instance Core.ToJSON LabelingJobDataSource where
  toJSON :: LabelingJobDataSource -> Value
toJSON LabelingJobDataSource' {Maybe LabelingJobS3DataSource
Maybe LabelingJobSnsDataSource
snsDataSource :: Maybe LabelingJobSnsDataSource
s3DataSource :: Maybe LabelingJobS3DataSource
$sel:snsDataSource:LabelingJobDataSource' :: LabelingJobDataSource -> Maybe LabelingJobSnsDataSource
$sel:s3DataSource:LabelingJobDataSource' :: LabelingJobDataSource -> Maybe LabelingJobS3DataSource
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"S3DataSource" Text -> LabelingJobS3DataSource -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (LabelingJobS3DataSource -> Pair)
-> Maybe LabelingJobS3DataSource -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe LabelingJobS3DataSource
s3DataSource,
            (Text
"SnsDataSource" Text -> LabelingJobSnsDataSource -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (LabelingJobSnsDataSource -> Pair)
-> Maybe LabelingJobSnsDataSource -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe LabelingJobSnsDataSource
snsDataSource
          ]
      )