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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MechanicalTurk.Types.ReviewActionStatus
import qualified Amazonka.Prelude as Prelude

-- | Both the AssignmentReviewReport and the HITReviewReport elements
-- contains the ReviewActionDetail data structure. This structure is
-- returned multiple times for each action specified in the Review Policy.
--
-- /See:/ 'newReviewActionDetail' smart constructor.
data ReviewActionDetail = ReviewActionDetail'
  { -- | The current disposition of the action: INTENDED, SUCCEEDED, FAILED, or
    -- CANCELLED.
    ReviewActionDetail -> Maybe ReviewActionStatus
status :: Prelude.Maybe ReviewActionStatus,
    -- | The specific HITId or AssignmentID targeted by the action.
    ReviewActionDetail -> Maybe Text
targetId :: Prelude.Maybe Prelude.Text,
    -- | The unique identifier for the action.
    ReviewActionDetail -> Maybe Text
actionId :: Prelude.Maybe Prelude.Text,
    -- | The type of object in TargetId.
    ReviewActionDetail -> Maybe Text
targetType :: Prelude.Maybe Prelude.Text,
    -- | A description of the outcome of the review.
    ReviewActionDetail -> Maybe Text
result :: Prelude.Maybe Prelude.Text,
    -- | The nature of the action itself. The Review Policy is responsible for
    -- examining the HIT and Assignments, emitting results, and deciding which
    -- other actions will be necessary.
    ReviewActionDetail -> Maybe Text
actionName :: Prelude.Maybe Prelude.Text,
    -- | The date when the action was completed.
    ReviewActionDetail -> Maybe POSIX
completeTime :: Prelude.Maybe Core.POSIX,
    -- | Present only when the Results have a FAILED Status.
    ReviewActionDetail -> Maybe Text
errorCode :: Prelude.Maybe Prelude.Text
  }
  deriving (ReviewActionDetail -> ReviewActionDetail -> Bool
(ReviewActionDetail -> ReviewActionDetail -> Bool)
-> (ReviewActionDetail -> ReviewActionDetail -> Bool)
-> Eq ReviewActionDetail
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ReviewActionDetail -> ReviewActionDetail -> Bool
$c/= :: ReviewActionDetail -> ReviewActionDetail -> Bool
== :: ReviewActionDetail -> ReviewActionDetail -> Bool
$c== :: ReviewActionDetail -> ReviewActionDetail -> Bool
Prelude.Eq, ReadPrec [ReviewActionDetail]
ReadPrec ReviewActionDetail
Int -> ReadS ReviewActionDetail
ReadS [ReviewActionDetail]
(Int -> ReadS ReviewActionDetail)
-> ReadS [ReviewActionDetail]
-> ReadPrec ReviewActionDetail
-> ReadPrec [ReviewActionDetail]
-> Read ReviewActionDetail
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ReviewActionDetail]
$creadListPrec :: ReadPrec [ReviewActionDetail]
readPrec :: ReadPrec ReviewActionDetail
$creadPrec :: ReadPrec ReviewActionDetail
readList :: ReadS [ReviewActionDetail]
$creadList :: ReadS [ReviewActionDetail]
readsPrec :: Int -> ReadS ReviewActionDetail
$creadsPrec :: Int -> ReadS ReviewActionDetail
Prelude.Read, Int -> ReviewActionDetail -> ShowS
[ReviewActionDetail] -> ShowS
ReviewActionDetail -> String
(Int -> ReviewActionDetail -> ShowS)
-> (ReviewActionDetail -> String)
-> ([ReviewActionDetail] -> ShowS)
-> Show ReviewActionDetail
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReviewActionDetail] -> ShowS
$cshowList :: [ReviewActionDetail] -> ShowS
show :: ReviewActionDetail -> String
$cshow :: ReviewActionDetail -> String
showsPrec :: Int -> ReviewActionDetail -> ShowS
$cshowsPrec :: Int -> ReviewActionDetail -> ShowS
Prelude.Show, (forall x. ReviewActionDetail -> Rep ReviewActionDetail x)
-> (forall x. Rep ReviewActionDetail x -> ReviewActionDetail)
-> Generic ReviewActionDetail
forall x. Rep ReviewActionDetail x -> ReviewActionDetail
forall x. ReviewActionDetail -> Rep ReviewActionDetail x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ReviewActionDetail x -> ReviewActionDetail
$cfrom :: forall x. ReviewActionDetail -> Rep ReviewActionDetail x
Prelude.Generic)

-- |
-- Create a value of 'ReviewActionDetail' 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:
--
-- 'status', 'reviewActionDetail_status' - The current disposition of the action: INTENDED, SUCCEEDED, FAILED, or
-- CANCELLED.
--
-- 'targetId', 'reviewActionDetail_targetId' - The specific HITId or AssignmentID targeted by the action.
--
-- 'actionId', 'reviewActionDetail_actionId' - The unique identifier for the action.
--
-- 'targetType', 'reviewActionDetail_targetType' - The type of object in TargetId.
--
-- 'result', 'reviewActionDetail_result' - A description of the outcome of the review.
--
-- 'actionName', 'reviewActionDetail_actionName' - The nature of the action itself. The Review Policy is responsible for
-- examining the HIT and Assignments, emitting results, and deciding which
-- other actions will be necessary.
--
-- 'completeTime', 'reviewActionDetail_completeTime' - The date when the action was completed.
--
-- 'errorCode', 'reviewActionDetail_errorCode' - Present only when the Results have a FAILED Status.
newReviewActionDetail ::
  ReviewActionDetail
newReviewActionDetail :: ReviewActionDetail
newReviewActionDetail =
  ReviewActionDetail' :: Maybe ReviewActionStatus
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe POSIX
-> Maybe Text
-> ReviewActionDetail
ReviewActionDetail'
    { $sel:status:ReviewActionDetail' :: Maybe ReviewActionStatus
status = Maybe ReviewActionStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:targetId:ReviewActionDetail' :: Maybe Text
targetId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:actionId:ReviewActionDetail' :: Maybe Text
actionId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:targetType:ReviewActionDetail' :: Maybe Text
targetType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:result:ReviewActionDetail' :: Maybe Text
result = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:actionName:ReviewActionDetail' :: Maybe Text
actionName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:completeTime:ReviewActionDetail' :: Maybe POSIX
completeTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:errorCode:ReviewActionDetail' :: Maybe Text
errorCode = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The current disposition of the action: INTENDED, SUCCEEDED, FAILED, or
-- CANCELLED.
reviewActionDetail_status :: Lens.Lens' ReviewActionDetail (Prelude.Maybe ReviewActionStatus)
reviewActionDetail_status :: (Maybe ReviewActionStatus -> f (Maybe ReviewActionStatus))
-> ReviewActionDetail -> f ReviewActionDetail
reviewActionDetail_status = (ReviewActionDetail -> Maybe ReviewActionStatus)
-> (ReviewActionDetail
    -> Maybe ReviewActionStatus -> ReviewActionDetail)
-> Lens
     ReviewActionDetail
     ReviewActionDetail
     (Maybe ReviewActionStatus)
     (Maybe ReviewActionStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReviewActionDetail' {Maybe ReviewActionStatus
status :: Maybe ReviewActionStatus
$sel:status:ReviewActionDetail' :: ReviewActionDetail -> Maybe ReviewActionStatus
status} -> Maybe ReviewActionStatus
status) (\s :: ReviewActionDetail
s@ReviewActionDetail' {} Maybe ReviewActionStatus
a -> ReviewActionDetail
s {$sel:status:ReviewActionDetail' :: Maybe ReviewActionStatus
status = Maybe ReviewActionStatus
a} :: ReviewActionDetail)

-- | The specific HITId or AssignmentID targeted by the action.
reviewActionDetail_targetId :: Lens.Lens' ReviewActionDetail (Prelude.Maybe Prelude.Text)
reviewActionDetail_targetId :: (Maybe Text -> f (Maybe Text))
-> ReviewActionDetail -> f ReviewActionDetail
reviewActionDetail_targetId = (ReviewActionDetail -> Maybe Text)
-> (ReviewActionDetail -> Maybe Text -> ReviewActionDetail)
-> Lens
     ReviewActionDetail ReviewActionDetail (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReviewActionDetail' {Maybe Text
targetId :: Maybe Text
$sel:targetId:ReviewActionDetail' :: ReviewActionDetail -> Maybe Text
targetId} -> Maybe Text
targetId) (\s :: ReviewActionDetail
s@ReviewActionDetail' {} Maybe Text
a -> ReviewActionDetail
s {$sel:targetId:ReviewActionDetail' :: Maybe Text
targetId = Maybe Text
a} :: ReviewActionDetail)

-- | The unique identifier for the action.
reviewActionDetail_actionId :: Lens.Lens' ReviewActionDetail (Prelude.Maybe Prelude.Text)
reviewActionDetail_actionId :: (Maybe Text -> f (Maybe Text))
-> ReviewActionDetail -> f ReviewActionDetail
reviewActionDetail_actionId = (ReviewActionDetail -> Maybe Text)
-> (ReviewActionDetail -> Maybe Text -> ReviewActionDetail)
-> Lens
     ReviewActionDetail ReviewActionDetail (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReviewActionDetail' {Maybe Text
actionId :: Maybe Text
$sel:actionId:ReviewActionDetail' :: ReviewActionDetail -> Maybe Text
actionId} -> Maybe Text
actionId) (\s :: ReviewActionDetail
s@ReviewActionDetail' {} Maybe Text
a -> ReviewActionDetail
s {$sel:actionId:ReviewActionDetail' :: Maybe Text
actionId = Maybe Text
a} :: ReviewActionDetail)

-- | The type of object in TargetId.
reviewActionDetail_targetType :: Lens.Lens' ReviewActionDetail (Prelude.Maybe Prelude.Text)
reviewActionDetail_targetType :: (Maybe Text -> f (Maybe Text))
-> ReviewActionDetail -> f ReviewActionDetail
reviewActionDetail_targetType = (ReviewActionDetail -> Maybe Text)
-> (ReviewActionDetail -> Maybe Text -> ReviewActionDetail)
-> Lens
     ReviewActionDetail ReviewActionDetail (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReviewActionDetail' {Maybe Text
targetType :: Maybe Text
$sel:targetType:ReviewActionDetail' :: ReviewActionDetail -> Maybe Text
targetType} -> Maybe Text
targetType) (\s :: ReviewActionDetail
s@ReviewActionDetail' {} Maybe Text
a -> ReviewActionDetail
s {$sel:targetType:ReviewActionDetail' :: Maybe Text
targetType = Maybe Text
a} :: ReviewActionDetail)

-- | A description of the outcome of the review.
reviewActionDetail_result :: Lens.Lens' ReviewActionDetail (Prelude.Maybe Prelude.Text)
reviewActionDetail_result :: (Maybe Text -> f (Maybe Text))
-> ReviewActionDetail -> f ReviewActionDetail
reviewActionDetail_result = (ReviewActionDetail -> Maybe Text)
-> (ReviewActionDetail -> Maybe Text -> ReviewActionDetail)
-> Lens
     ReviewActionDetail ReviewActionDetail (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReviewActionDetail' {Maybe Text
result :: Maybe Text
$sel:result:ReviewActionDetail' :: ReviewActionDetail -> Maybe Text
result} -> Maybe Text
result) (\s :: ReviewActionDetail
s@ReviewActionDetail' {} Maybe Text
a -> ReviewActionDetail
s {$sel:result:ReviewActionDetail' :: Maybe Text
result = Maybe Text
a} :: ReviewActionDetail)

-- | The nature of the action itself. The Review Policy is responsible for
-- examining the HIT and Assignments, emitting results, and deciding which
-- other actions will be necessary.
reviewActionDetail_actionName :: Lens.Lens' ReviewActionDetail (Prelude.Maybe Prelude.Text)
reviewActionDetail_actionName :: (Maybe Text -> f (Maybe Text))
-> ReviewActionDetail -> f ReviewActionDetail
reviewActionDetail_actionName = (ReviewActionDetail -> Maybe Text)
-> (ReviewActionDetail -> Maybe Text -> ReviewActionDetail)
-> Lens
     ReviewActionDetail ReviewActionDetail (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReviewActionDetail' {Maybe Text
actionName :: Maybe Text
$sel:actionName:ReviewActionDetail' :: ReviewActionDetail -> Maybe Text
actionName} -> Maybe Text
actionName) (\s :: ReviewActionDetail
s@ReviewActionDetail' {} Maybe Text
a -> ReviewActionDetail
s {$sel:actionName:ReviewActionDetail' :: Maybe Text
actionName = Maybe Text
a} :: ReviewActionDetail)

-- | The date when the action was completed.
reviewActionDetail_completeTime :: Lens.Lens' ReviewActionDetail (Prelude.Maybe Prelude.UTCTime)
reviewActionDetail_completeTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ReviewActionDetail -> f ReviewActionDetail
reviewActionDetail_completeTime = (ReviewActionDetail -> Maybe POSIX)
-> (ReviewActionDetail -> Maybe POSIX -> ReviewActionDetail)
-> Lens
     ReviewActionDetail ReviewActionDetail (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReviewActionDetail' {Maybe POSIX
completeTime :: Maybe POSIX
$sel:completeTime:ReviewActionDetail' :: ReviewActionDetail -> Maybe POSIX
completeTime} -> Maybe POSIX
completeTime) (\s :: ReviewActionDetail
s@ReviewActionDetail' {} Maybe POSIX
a -> ReviewActionDetail
s {$sel:completeTime:ReviewActionDetail' :: Maybe POSIX
completeTime = Maybe POSIX
a} :: ReviewActionDetail) ((Maybe POSIX -> f (Maybe POSIX))
 -> ReviewActionDetail -> f ReviewActionDetail)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ReviewActionDetail
-> f ReviewActionDetail
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | Present only when the Results have a FAILED Status.
reviewActionDetail_errorCode :: Lens.Lens' ReviewActionDetail (Prelude.Maybe Prelude.Text)
reviewActionDetail_errorCode :: (Maybe Text -> f (Maybe Text))
-> ReviewActionDetail -> f ReviewActionDetail
reviewActionDetail_errorCode = (ReviewActionDetail -> Maybe Text)
-> (ReviewActionDetail -> Maybe Text -> ReviewActionDetail)
-> Lens
     ReviewActionDetail ReviewActionDetail (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReviewActionDetail' {Maybe Text
errorCode :: Maybe Text
$sel:errorCode:ReviewActionDetail' :: ReviewActionDetail -> Maybe Text
errorCode} -> Maybe Text
errorCode) (\s :: ReviewActionDetail
s@ReviewActionDetail' {} Maybe Text
a -> ReviewActionDetail
s {$sel:errorCode:ReviewActionDetail' :: Maybe Text
errorCode = Maybe Text
a} :: ReviewActionDetail)

instance Core.FromJSON ReviewActionDetail where
  parseJSON :: Value -> Parser ReviewActionDetail
parseJSON =
    String
-> (Object -> Parser ReviewActionDetail)
-> Value
-> Parser ReviewActionDetail
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ReviewActionDetail"
      ( \Object
x ->
          Maybe ReviewActionStatus
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe POSIX
-> Maybe Text
-> ReviewActionDetail
ReviewActionDetail'
            (Maybe ReviewActionStatus
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe POSIX
 -> Maybe Text
 -> ReviewActionDetail)
-> Parser (Maybe ReviewActionStatus)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe POSIX
      -> Maybe Text
      -> ReviewActionDetail)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ReviewActionStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Status")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe POSIX
   -> Maybe Text
   -> ReviewActionDetail)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe POSIX
      -> Maybe Text
      -> ReviewActionDetail)
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
"TargetId")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe POSIX
   -> Maybe Text
   -> ReviewActionDetail)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe POSIX
      -> Maybe Text
      -> ReviewActionDetail)
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
"ActionId")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe POSIX
   -> Maybe Text
   -> ReviewActionDetail)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe POSIX -> Maybe Text -> ReviewActionDetail)
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
"TargetType")
            Parser
  (Maybe Text
   -> Maybe Text -> Maybe POSIX -> Maybe Text -> ReviewActionDetail)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe POSIX -> Maybe Text -> ReviewActionDetail)
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
"Result")
            Parser
  (Maybe Text -> Maybe POSIX -> Maybe Text -> ReviewActionDetail)
-> Parser (Maybe Text)
-> Parser (Maybe POSIX -> Maybe Text -> ReviewActionDetail)
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
"ActionName")
            Parser (Maybe POSIX -> Maybe Text -> ReviewActionDetail)
-> Parser (Maybe POSIX)
-> Parser (Maybe Text -> ReviewActionDetail)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CompleteTime")
            Parser (Maybe Text -> ReviewActionDetail)
-> Parser (Maybe Text) -> Parser ReviewActionDetail
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
"ErrorCode")
      )

instance Prelude.Hashable ReviewActionDetail

instance Prelude.NFData ReviewActionDetail