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

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

-- | A set of conditions for stopping a labeling job. If any of the
-- conditions are met, the job is automatically stopped. You can use these
-- conditions to control the cost of data labeling.
--
-- Labeling jobs fail after 30 days with an appropriate client error
-- message.
--
-- /See:/ 'newLabelingJobStoppingConditions' smart constructor.
data LabelingJobStoppingConditions = LabelingJobStoppingConditions'
  { -- | The maximum number of objects that can be labeled by human workers.
    LabelingJobStoppingConditions -> Maybe Natural
maxHumanLabeledObjectCount :: Prelude.Maybe Prelude.Natural,
    -- | The maximum number of input data objects that should be labeled.
    LabelingJobStoppingConditions -> Maybe Natural
maxPercentageOfInputDatasetLabeled :: Prelude.Maybe Prelude.Natural
  }
  deriving (LabelingJobStoppingConditions
-> LabelingJobStoppingConditions -> Bool
(LabelingJobStoppingConditions
 -> LabelingJobStoppingConditions -> Bool)
-> (LabelingJobStoppingConditions
    -> LabelingJobStoppingConditions -> Bool)
-> Eq LabelingJobStoppingConditions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LabelingJobStoppingConditions
-> LabelingJobStoppingConditions -> Bool
$c/= :: LabelingJobStoppingConditions
-> LabelingJobStoppingConditions -> Bool
== :: LabelingJobStoppingConditions
-> LabelingJobStoppingConditions -> Bool
$c== :: LabelingJobStoppingConditions
-> LabelingJobStoppingConditions -> Bool
Prelude.Eq, ReadPrec [LabelingJobStoppingConditions]
ReadPrec LabelingJobStoppingConditions
Int -> ReadS LabelingJobStoppingConditions
ReadS [LabelingJobStoppingConditions]
(Int -> ReadS LabelingJobStoppingConditions)
-> ReadS [LabelingJobStoppingConditions]
-> ReadPrec LabelingJobStoppingConditions
-> ReadPrec [LabelingJobStoppingConditions]
-> Read LabelingJobStoppingConditions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LabelingJobStoppingConditions]
$creadListPrec :: ReadPrec [LabelingJobStoppingConditions]
readPrec :: ReadPrec LabelingJobStoppingConditions
$creadPrec :: ReadPrec LabelingJobStoppingConditions
readList :: ReadS [LabelingJobStoppingConditions]
$creadList :: ReadS [LabelingJobStoppingConditions]
readsPrec :: Int -> ReadS LabelingJobStoppingConditions
$creadsPrec :: Int -> ReadS LabelingJobStoppingConditions
Prelude.Read, Int -> LabelingJobStoppingConditions -> ShowS
[LabelingJobStoppingConditions] -> ShowS
LabelingJobStoppingConditions -> String
(Int -> LabelingJobStoppingConditions -> ShowS)
-> (LabelingJobStoppingConditions -> String)
-> ([LabelingJobStoppingConditions] -> ShowS)
-> Show LabelingJobStoppingConditions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LabelingJobStoppingConditions] -> ShowS
$cshowList :: [LabelingJobStoppingConditions] -> ShowS
show :: LabelingJobStoppingConditions -> String
$cshow :: LabelingJobStoppingConditions -> String
showsPrec :: Int -> LabelingJobStoppingConditions -> ShowS
$cshowsPrec :: Int -> LabelingJobStoppingConditions -> ShowS
Prelude.Show, (forall x.
 LabelingJobStoppingConditions
 -> Rep LabelingJobStoppingConditions x)
-> (forall x.
    Rep LabelingJobStoppingConditions x
    -> LabelingJobStoppingConditions)
-> Generic LabelingJobStoppingConditions
forall x.
Rep LabelingJobStoppingConditions x
-> LabelingJobStoppingConditions
forall x.
LabelingJobStoppingConditions
-> Rep LabelingJobStoppingConditions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep LabelingJobStoppingConditions x
-> LabelingJobStoppingConditions
$cfrom :: forall x.
LabelingJobStoppingConditions
-> Rep LabelingJobStoppingConditions x
Prelude.Generic)

-- |
-- Create a value of 'LabelingJobStoppingConditions' 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:
--
-- 'maxHumanLabeledObjectCount', 'labelingJobStoppingConditions_maxHumanLabeledObjectCount' - The maximum number of objects that can be labeled by human workers.
--
-- 'maxPercentageOfInputDatasetLabeled', 'labelingJobStoppingConditions_maxPercentageOfInputDatasetLabeled' - The maximum number of input data objects that should be labeled.
newLabelingJobStoppingConditions ::
  LabelingJobStoppingConditions
newLabelingJobStoppingConditions :: LabelingJobStoppingConditions
newLabelingJobStoppingConditions =
  LabelingJobStoppingConditions' :: Maybe Natural -> Maybe Natural -> LabelingJobStoppingConditions
LabelingJobStoppingConditions'
    { $sel:maxHumanLabeledObjectCount:LabelingJobStoppingConditions' :: Maybe Natural
maxHumanLabeledObjectCount =
        Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:maxPercentageOfInputDatasetLabeled:LabelingJobStoppingConditions' :: Maybe Natural
maxPercentageOfInputDatasetLabeled =
        Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of objects that can be labeled by human workers.
labelingJobStoppingConditions_maxHumanLabeledObjectCount :: Lens.Lens' LabelingJobStoppingConditions (Prelude.Maybe Prelude.Natural)
labelingJobStoppingConditions_maxHumanLabeledObjectCount :: (Maybe Natural -> f (Maybe Natural))
-> LabelingJobStoppingConditions -> f LabelingJobStoppingConditions
labelingJobStoppingConditions_maxHumanLabeledObjectCount = (LabelingJobStoppingConditions -> Maybe Natural)
-> (LabelingJobStoppingConditions
    -> Maybe Natural -> LabelingJobStoppingConditions)
-> Lens
     LabelingJobStoppingConditions
     LabelingJobStoppingConditions
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LabelingJobStoppingConditions' {Maybe Natural
maxHumanLabeledObjectCount :: Maybe Natural
$sel:maxHumanLabeledObjectCount:LabelingJobStoppingConditions' :: LabelingJobStoppingConditions -> Maybe Natural
maxHumanLabeledObjectCount} -> Maybe Natural
maxHumanLabeledObjectCount) (\s :: LabelingJobStoppingConditions
s@LabelingJobStoppingConditions' {} Maybe Natural
a -> LabelingJobStoppingConditions
s {$sel:maxHumanLabeledObjectCount:LabelingJobStoppingConditions' :: Maybe Natural
maxHumanLabeledObjectCount = Maybe Natural
a} :: LabelingJobStoppingConditions)

-- | The maximum number of input data objects that should be labeled.
labelingJobStoppingConditions_maxPercentageOfInputDatasetLabeled :: Lens.Lens' LabelingJobStoppingConditions (Prelude.Maybe Prelude.Natural)
labelingJobStoppingConditions_maxPercentageOfInputDatasetLabeled :: (Maybe Natural -> f (Maybe Natural))
-> LabelingJobStoppingConditions -> f LabelingJobStoppingConditions
labelingJobStoppingConditions_maxPercentageOfInputDatasetLabeled = (LabelingJobStoppingConditions -> Maybe Natural)
-> (LabelingJobStoppingConditions
    -> Maybe Natural -> LabelingJobStoppingConditions)
-> Lens
     LabelingJobStoppingConditions
     LabelingJobStoppingConditions
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LabelingJobStoppingConditions' {Maybe Natural
maxPercentageOfInputDatasetLabeled :: Maybe Natural
$sel:maxPercentageOfInputDatasetLabeled:LabelingJobStoppingConditions' :: LabelingJobStoppingConditions -> Maybe Natural
maxPercentageOfInputDatasetLabeled} -> Maybe Natural
maxPercentageOfInputDatasetLabeled) (\s :: LabelingJobStoppingConditions
s@LabelingJobStoppingConditions' {} Maybe Natural
a -> LabelingJobStoppingConditions
s {$sel:maxPercentageOfInputDatasetLabeled:LabelingJobStoppingConditions' :: Maybe Natural
maxPercentageOfInputDatasetLabeled = Maybe Natural
a} :: LabelingJobStoppingConditions)

instance Core.FromJSON LabelingJobStoppingConditions where
  parseJSON :: Value -> Parser LabelingJobStoppingConditions
parseJSON =
    String
-> (Object -> Parser LabelingJobStoppingConditions)
-> Value
-> Parser LabelingJobStoppingConditions
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"LabelingJobStoppingConditions"
      ( \Object
x ->
          Maybe Natural -> Maybe Natural -> LabelingJobStoppingConditions
LabelingJobStoppingConditions'
            (Maybe Natural -> Maybe Natural -> LabelingJobStoppingConditions)
-> Parser (Maybe Natural)
-> Parser (Maybe Natural -> LabelingJobStoppingConditions)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MaxHumanLabeledObjectCount")
            Parser (Maybe Natural -> LabelingJobStoppingConditions)
-> Parser (Maybe Natural) -> Parser LabelingJobStoppingConditions
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MaxPercentageOfInputDatasetLabeled")
      )

instance
  Prelude.Hashable
    LabelingJobStoppingConditions

instance Prelude.NFData LabelingJobStoppingConditions

instance Core.ToJSON LabelingJobStoppingConditions where
  toJSON :: LabelingJobStoppingConditions -> Value
toJSON LabelingJobStoppingConditions' {Maybe Natural
maxPercentageOfInputDatasetLabeled :: Maybe Natural
maxHumanLabeledObjectCount :: Maybe Natural
$sel:maxPercentageOfInputDatasetLabeled:LabelingJobStoppingConditions' :: LabelingJobStoppingConditions -> Maybe Natural
$sel:maxHumanLabeledObjectCount:LabelingJobStoppingConditions' :: LabelingJobStoppingConditions -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"MaxHumanLabeledObjectCount" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxHumanLabeledObjectCount,
            (Text
"MaxPercentageOfInputDatasetLabeled" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxPercentageOfInputDatasetLabeled
          ]
      )