{-# 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.Textract.Types.HumanLoopConfig
-- 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.Textract.Types.HumanLoopConfig where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Textract.Types.HumanLoopDataAttributes

-- | Sets up the human review workflow the document will be sent to if one of
-- the conditions is met. You can also set certain attributes of the image
-- before review.
--
-- /See:/ 'newHumanLoopConfig' smart constructor.
data HumanLoopConfig = HumanLoopConfig'
  { -- | Sets attributes of the input data.
    HumanLoopConfig -> Maybe HumanLoopDataAttributes
dataAttributes :: Prelude.Maybe HumanLoopDataAttributes,
    -- | The name of the human workflow used for this image. This should be kept
    -- unique within a region.
    HumanLoopConfig -> Text
humanLoopName :: Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the flow definition.
    HumanLoopConfig -> Text
flowDefinitionArn :: Prelude.Text
  }
  deriving (HumanLoopConfig -> HumanLoopConfig -> Bool
(HumanLoopConfig -> HumanLoopConfig -> Bool)
-> (HumanLoopConfig -> HumanLoopConfig -> Bool)
-> Eq HumanLoopConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HumanLoopConfig -> HumanLoopConfig -> Bool
$c/= :: HumanLoopConfig -> HumanLoopConfig -> Bool
== :: HumanLoopConfig -> HumanLoopConfig -> Bool
$c== :: HumanLoopConfig -> HumanLoopConfig -> Bool
Prelude.Eq, ReadPrec [HumanLoopConfig]
ReadPrec HumanLoopConfig
Int -> ReadS HumanLoopConfig
ReadS [HumanLoopConfig]
(Int -> ReadS HumanLoopConfig)
-> ReadS [HumanLoopConfig]
-> ReadPrec HumanLoopConfig
-> ReadPrec [HumanLoopConfig]
-> Read HumanLoopConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HumanLoopConfig]
$creadListPrec :: ReadPrec [HumanLoopConfig]
readPrec :: ReadPrec HumanLoopConfig
$creadPrec :: ReadPrec HumanLoopConfig
readList :: ReadS [HumanLoopConfig]
$creadList :: ReadS [HumanLoopConfig]
readsPrec :: Int -> ReadS HumanLoopConfig
$creadsPrec :: Int -> ReadS HumanLoopConfig
Prelude.Read, Int -> HumanLoopConfig -> ShowS
[HumanLoopConfig] -> ShowS
HumanLoopConfig -> String
(Int -> HumanLoopConfig -> ShowS)
-> (HumanLoopConfig -> String)
-> ([HumanLoopConfig] -> ShowS)
-> Show HumanLoopConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HumanLoopConfig] -> ShowS
$cshowList :: [HumanLoopConfig] -> ShowS
show :: HumanLoopConfig -> String
$cshow :: HumanLoopConfig -> String
showsPrec :: Int -> HumanLoopConfig -> ShowS
$cshowsPrec :: Int -> HumanLoopConfig -> ShowS
Prelude.Show, (forall x. HumanLoopConfig -> Rep HumanLoopConfig x)
-> (forall x. Rep HumanLoopConfig x -> HumanLoopConfig)
-> Generic HumanLoopConfig
forall x. Rep HumanLoopConfig x -> HumanLoopConfig
forall x. HumanLoopConfig -> Rep HumanLoopConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HumanLoopConfig x -> HumanLoopConfig
$cfrom :: forall x. HumanLoopConfig -> Rep HumanLoopConfig x
Prelude.Generic)

-- |
-- Create a value of 'HumanLoopConfig' 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:
--
-- 'dataAttributes', 'humanLoopConfig_dataAttributes' - Sets attributes of the input data.
--
-- 'humanLoopName', 'humanLoopConfig_humanLoopName' - The name of the human workflow used for this image. This should be kept
-- unique within a region.
--
-- 'flowDefinitionArn', 'humanLoopConfig_flowDefinitionArn' - The Amazon Resource Name (ARN) of the flow definition.
newHumanLoopConfig ::
  -- | 'humanLoopName'
  Prelude.Text ->
  -- | 'flowDefinitionArn'
  Prelude.Text ->
  HumanLoopConfig
newHumanLoopConfig :: Text -> Text -> HumanLoopConfig
newHumanLoopConfig
  Text
pHumanLoopName_
  Text
pFlowDefinitionArn_ =
    HumanLoopConfig' :: Maybe HumanLoopDataAttributes -> Text -> Text -> HumanLoopConfig
HumanLoopConfig'
      { $sel:dataAttributes:HumanLoopConfig' :: Maybe HumanLoopDataAttributes
dataAttributes = Maybe HumanLoopDataAttributes
forall a. Maybe a
Prelude.Nothing,
        $sel:humanLoopName:HumanLoopConfig' :: Text
humanLoopName = Text
pHumanLoopName_,
        $sel:flowDefinitionArn:HumanLoopConfig' :: Text
flowDefinitionArn = Text
pFlowDefinitionArn_
      }

-- | Sets attributes of the input data.
humanLoopConfig_dataAttributes :: Lens.Lens' HumanLoopConfig (Prelude.Maybe HumanLoopDataAttributes)
humanLoopConfig_dataAttributes :: (Maybe HumanLoopDataAttributes
 -> f (Maybe HumanLoopDataAttributes))
-> HumanLoopConfig -> f HumanLoopConfig
humanLoopConfig_dataAttributes = (HumanLoopConfig -> Maybe HumanLoopDataAttributes)
-> (HumanLoopConfig
    -> Maybe HumanLoopDataAttributes -> HumanLoopConfig)
-> Lens
     HumanLoopConfig
     HumanLoopConfig
     (Maybe HumanLoopDataAttributes)
     (Maybe HumanLoopDataAttributes)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HumanLoopConfig' {Maybe HumanLoopDataAttributes
dataAttributes :: Maybe HumanLoopDataAttributes
$sel:dataAttributes:HumanLoopConfig' :: HumanLoopConfig -> Maybe HumanLoopDataAttributes
dataAttributes} -> Maybe HumanLoopDataAttributes
dataAttributes) (\s :: HumanLoopConfig
s@HumanLoopConfig' {} Maybe HumanLoopDataAttributes
a -> HumanLoopConfig
s {$sel:dataAttributes:HumanLoopConfig' :: Maybe HumanLoopDataAttributes
dataAttributes = Maybe HumanLoopDataAttributes
a} :: HumanLoopConfig)

-- | The name of the human workflow used for this image. This should be kept
-- unique within a region.
humanLoopConfig_humanLoopName :: Lens.Lens' HumanLoopConfig Prelude.Text
humanLoopConfig_humanLoopName :: (Text -> f Text) -> HumanLoopConfig -> f HumanLoopConfig
humanLoopConfig_humanLoopName = (HumanLoopConfig -> Text)
-> (HumanLoopConfig -> Text -> HumanLoopConfig)
-> Lens HumanLoopConfig HumanLoopConfig Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HumanLoopConfig' {Text
humanLoopName :: Text
$sel:humanLoopName:HumanLoopConfig' :: HumanLoopConfig -> Text
humanLoopName} -> Text
humanLoopName) (\s :: HumanLoopConfig
s@HumanLoopConfig' {} Text
a -> HumanLoopConfig
s {$sel:humanLoopName:HumanLoopConfig' :: Text
humanLoopName = Text
a} :: HumanLoopConfig)

-- | The Amazon Resource Name (ARN) of the flow definition.
humanLoopConfig_flowDefinitionArn :: Lens.Lens' HumanLoopConfig Prelude.Text
humanLoopConfig_flowDefinitionArn :: (Text -> f Text) -> HumanLoopConfig -> f HumanLoopConfig
humanLoopConfig_flowDefinitionArn = (HumanLoopConfig -> Text)
-> (HumanLoopConfig -> Text -> HumanLoopConfig)
-> Lens HumanLoopConfig HumanLoopConfig Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HumanLoopConfig' {Text
flowDefinitionArn :: Text
$sel:flowDefinitionArn:HumanLoopConfig' :: HumanLoopConfig -> Text
flowDefinitionArn} -> Text
flowDefinitionArn) (\s :: HumanLoopConfig
s@HumanLoopConfig' {} Text
a -> HumanLoopConfig
s {$sel:flowDefinitionArn:HumanLoopConfig' :: Text
flowDefinitionArn = Text
a} :: HumanLoopConfig)

instance Prelude.Hashable HumanLoopConfig

instance Prelude.NFData HumanLoopConfig

instance Core.ToJSON HumanLoopConfig where
  toJSON :: HumanLoopConfig -> Value
toJSON HumanLoopConfig' {Maybe HumanLoopDataAttributes
Text
flowDefinitionArn :: Text
humanLoopName :: Text
dataAttributes :: Maybe HumanLoopDataAttributes
$sel:flowDefinitionArn:HumanLoopConfig' :: HumanLoopConfig -> Text
$sel:humanLoopName:HumanLoopConfig' :: HumanLoopConfig -> Text
$sel:dataAttributes:HumanLoopConfig' :: HumanLoopConfig -> Maybe HumanLoopDataAttributes
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"DataAttributes" Text -> HumanLoopDataAttributes -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (HumanLoopDataAttributes -> Pair)
-> Maybe HumanLoopDataAttributes -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe HumanLoopDataAttributes
dataAttributes,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"HumanLoopName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
humanLoopName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"FlowDefinitionArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
flowDefinitionArn)
          ]
      )