{-# 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.MechanicalTurk.Types.WorkerBlock
-- 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.MechanicalTurk.Types.WorkerBlock where

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

-- | The WorkerBlock data structure represents a Worker who has been blocked.
-- It has two elements: the WorkerId and the Reason for the block.
--
-- /See:/ 'newWorkerBlock' smart constructor.
data WorkerBlock = WorkerBlock'
  { -- | A message explaining the reason the Worker was blocked.
    WorkerBlock -> Maybe Text
reason :: Prelude.Maybe Prelude.Text,
    -- | The ID of the Worker who accepted the HIT.
    WorkerBlock -> Maybe Text
workerId :: Prelude.Maybe Prelude.Text
  }
  deriving (WorkerBlock -> WorkerBlock -> Bool
(WorkerBlock -> WorkerBlock -> Bool)
-> (WorkerBlock -> WorkerBlock -> Bool) -> Eq WorkerBlock
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WorkerBlock -> WorkerBlock -> Bool
$c/= :: WorkerBlock -> WorkerBlock -> Bool
== :: WorkerBlock -> WorkerBlock -> Bool
$c== :: WorkerBlock -> WorkerBlock -> Bool
Prelude.Eq, ReadPrec [WorkerBlock]
ReadPrec WorkerBlock
Int -> ReadS WorkerBlock
ReadS [WorkerBlock]
(Int -> ReadS WorkerBlock)
-> ReadS [WorkerBlock]
-> ReadPrec WorkerBlock
-> ReadPrec [WorkerBlock]
-> Read WorkerBlock
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WorkerBlock]
$creadListPrec :: ReadPrec [WorkerBlock]
readPrec :: ReadPrec WorkerBlock
$creadPrec :: ReadPrec WorkerBlock
readList :: ReadS [WorkerBlock]
$creadList :: ReadS [WorkerBlock]
readsPrec :: Int -> ReadS WorkerBlock
$creadsPrec :: Int -> ReadS WorkerBlock
Prelude.Read, Int -> WorkerBlock -> ShowS
[WorkerBlock] -> ShowS
WorkerBlock -> String
(Int -> WorkerBlock -> ShowS)
-> (WorkerBlock -> String)
-> ([WorkerBlock] -> ShowS)
-> Show WorkerBlock
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WorkerBlock] -> ShowS
$cshowList :: [WorkerBlock] -> ShowS
show :: WorkerBlock -> String
$cshow :: WorkerBlock -> String
showsPrec :: Int -> WorkerBlock -> ShowS
$cshowsPrec :: Int -> WorkerBlock -> ShowS
Prelude.Show, (forall x. WorkerBlock -> Rep WorkerBlock x)
-> (forall x. Rep WorkerBlock x -> WorkerBlock)
-> Generic WorkerBlock
forall x. Rep WorkerBlock x -> WorkerBlock
forall x. WorkerBlock -> Rep WorkerBlock x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep WorkerBlock x -> WorkerBlock
$cfrom :: forall x. WorkerBlock -> Rep WorkerBlock x
Prelude.Generic)

-- |
-- Create a value of 'WorkerBlock' 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:
--
-- 'reason', 'workerBlock_reason' - A message explaining the reason the Worker was blocked.
--
-- 'workerId', 'workerBlock_workerId' - The ID of the Worker who accepted the HIT.
newWorkerBlock ::
  WorkerBlock
newWorkerBlock :: WorkerBlock
newWorkerBlock =
  WorkerBlock' :: Maybe Text -> Maybe Text -> WorkerBlock
WorkerBlock'
    { $sel:reason:WorkerBlock' :: Maybe Text
reason = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:workerId:WorkerBlock' :: Maybe Text
workerId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | A message explaining the reason the Worker was blocked.
workerBlock_reason :: Lens.Lens' WorkerBlock (Prelude.Maybe Prelude.Text)
workerBlock_reason :: (Maybe Text -> f (Maybe Text)) -> WorkerBlock -> f WorkerBlock
workerBlock_reason = (WorkerBlock -> Maybe Text)
-> (WorkerBlock -> Maybe Text -> WorkerBlock)
-> Lens WorkerBlock WorkerBlock (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorkerBlock' {Maybe Text
reason :: Maybe Text
$sel:reason:WorkerBlock' :: WorkerBlock -> Maybe Text
reason} -> Maybe Text
reason) (\s :: WorkerBlock
s@WorkerBlock' {} Maybe Text
a -> WorkerBlock
s {$sel:reason:WorkerBlock' :: Maybe Text
reason = Maybe Text
a} :: WorkerBlock)

-- | The ID of the Worker who accepted the HIT.
workerBlock_workerId :: Lens.Lens' WorkerBlock (Prelude.Maybe Prelude.Text)
workerBlock_workerId :: (Maybe Text -> f (Maybe Text)) -> WorkerBlock -> f WorkerBlock
workerBlock_workerId = (WorkerBlock -> Maybe Text)
-> (WorkerBlock -> Maybe Text -> WorkerBlock)
-> Lens WorkerBlock WorkerBlock (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorkerBlock' {Maybe Text
workerId :: Maybe Text
$sel:workerId:WorkerBlock' :: WorkerBlock -> Maybe Text
workerId} -> Maybe Text
workerId) (\s :: WorkerBlock
s@WorkerBlock' {} Maybe Text
a -> WorkerBlock
s {$sel:workerId:WorkerBlock' :: Maybe Text
workerId = Maybe Text
a} :: WorkerBlock)

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

instance Prelude.Hashable WorkerBlock

instance Prelude.NFData WorkerBlock