{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.MechanicalTurk.Types.WorkerBlock where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
    { $sel:reason:WorkerBlock' :: Maybe Text
reason = forall a. Maybe a
Prelude.Nothing,
      $sel:workerId:WorkerBlock' :: Maybe Text
workerId = 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 :: Lens' WorkerBlock (Maybe Text)
workerBlock_reason = 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 :: Lens' WorkerBlock (Maybe Text)
workerBlock_workerId = 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 Data.FromJSON WorkerBlock where
  parseJSON :: Value -> Parser WorkerBlock
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"WorkerBlock"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> WorkerBlock
WorkerBlock'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Reason")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"WorkerId")
      )

instance Prelude.Hashable WorkerBlock where
  hashWithSalt :: Int -> WorkerBlock -> Int
hashWithSalt Int
_salt WorkerBlock' {Maybe Text
workerId :: Maybe Text
reason :: Maybe Text
$sel:workerId:WorkerBlock' :: WorkerBlock -> Maybe Text
$sel:reason:WorkerBlock' :: WorkerBlock -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
reason
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
workerId

instance Prelude.NFData WorkerBlock where
  rnf :: WorkerBlock -> ()
rnf WorkerBlock' {Maybe Text
workerId :: Maybe Text
reason :: Maybe Text
$sel:workerId:WorkerBlock' :: WorkerBlock -> Maybe Text
$sel:reason:WorkerBlock' :: WorkerBlock -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
reason
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
workerId