{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.UpdateHITReviewStatus
-- 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)
--
-- The @UpdateHITReviewStatus@ operation updates the status of a HIT. If
-- the status is Reviewable, this operation can update the status to
-- Reviewing, or it can revert a Reviewing HIT back to the Reviewable
-- status.
module Amazonka.MechanicalTurk.UpdateHITReviewStatus
  ( -- * Creating a Request
    UpdateHITReviewStatus (..),
    newUpdateHITReviewStatus,

    -- * Request Lenses
    updateHITReviewStatus_revert,
    updateHITReviewStatus_hITId,

    -- * Destructuring the Response
    UpdateHITReviewStatusResponse (..),
    newUpdateHITReviewStatusResponse,

    -- * Response Lenses
    updateHITReviewStatusResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MechanicalTurk.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newUpdateHITReviewStatus' smart constructor.
data UpdateHITReviewStatus = UpdateHITReviewStatus'
  { -- | Specifies how to update the HIT status. Default is @False@.
    --
    -- -   Setting this to false will only transition a HIT from @Reviewable@
    --     to @Reviewing@
    --
    -- -   Setting this to true will only transition a HIT from @Reviewing@ to
    --     @Reviewable@
    UpdateHITReviewStatus -> Maybe Bool
revert :: Prelude.Maybe Prelude.Bool,
    -- | The ID of the HIT to update.
    UpdateHITReviewStatus -> Text
hITId :: Prelude.Text
  }
  deriving (UpdateHITReviewStatus -> UpdateHITReviewStatus -> Bool
(UpdateHITReviewStatus -> UpdateHITReviewStatus -> Bool)
-> (UpdateHITReviewStatus -> UpdateHITReviewStatus -> Bool)
-> Eq UpdateHITReviewStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateHITReviewStatus -> UpdateHITReviewStatus -> Bool
$c/= :: UpdateHITReviewStatus -> UpdateHITReviewStatus -> Bool
== :: UpdateHITReviewStatus -> UpdateHITReviewStatus -> Bool
$c== :: UpdateHITReviewStatus -> UpdateHITReviewStatus -> Bool
Prelude.Eq, ReadPrec [UpdateHITReviewStatus]
ReadPrec UpdateHITReviewStatus
Int -> ReadS UpdateHITReviewStatus
ReadS [UpdateHITReviewStatus]
(Int -> ReadS UpdateHITReviewStatus)
-> ReadS [UpdateHITReviewStatus]
-> ReadPrec UpdateHITReviewStatus
-> ReadPrec [UpdateHITReviewStatus]
-> Read UpdateHITReviewStatus
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateHITReviewStatus]
$creadListPrec :: ReadPrec [UpdateHITReviewStatus]
readPrec :: ReadPrec UpdateHITReviewStatus
$creadPrec :: ReadPrec UpdateHITReviewStatus
readList :: ReadS [UpdateHITReviewStatus]
$creadList :: ReadS [UpdateHITReviewStatus]
readsPrec :: Int -> ReadS UpdateHITReviewStatus
$creadsPrec :: Int -> ReadS UpdateHITReviewStatus
Prelude.Read, Int -> UpdateHITReviewStatus -> ShowS
[UpdateHITReviewStatus] -> ShowS
UpdateHITReviewStatus -> String
(Int -> UpdateHITReviewStatus -> ShowS)
-> (UpdateHITReviewStatus -> String)
-> ([UpdateHITReviewStatus] -> ShowS)
-> Show UpdateHITReviewStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateHITReviewStatus] -> ShowS
$cshowList :: [UpdateHITReviewStatus] -> ShowS
show :: UpdateHITReviewStatus -> String
$cshow :: UpdateHITReviewStatus -> String
showsPrec :: Int -> UpdateHITReviewStatus -> ShowS
$cshowsPrec :: Int -> UpdateHITReviewStatus -> ShowS
Prelude.Show, (forall x. UpdateHITReviewStatus -> Rep UpdateHITReviewStatus x)
-> (forall x. Rep UpdateHITReviewStatus x -> UpdateHITReviewStatus)
-> Generic UpdateHITReviewStatus
forall x. Rep UpdateHITReviewStatus x -> UpdateHITReviewStatus
forall x. UpdateHITReviewStatus -> Rep UpdateHITReviewStatus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateHITReviewStatus x -> UpdateHITReviewStatus
$cfrom :: forall x. UpdateHITReviewStatus -> Rep UpdateHITReviewStatus x
Prelude.Generic)

-- |
-- Create a value of 'UpdateHITReviewStatus' 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:
--
-- 'revert', 'updateHITReviewStatus_revert' - Specifies how to update the HIT status. Default is @False@.
--
-- -   Setting this to false will only transition a HIT from @Reviewable@
--     to @Reviewing@
--
-- -   Setting this to true will only transition a HIT from @Reviewing@ to
--     @Reviewable@
--
-- 'hITId', 'updateHITReviewStatus_hITId' - The ID of the HIT to update.
newUpdateHITReviewStatus ::
  -- | 'hITId'
  Prelude.Text ->
  UpdateHITReviewStatus
newUpdateHITReviewStatus :: Text -> UpdateHITReviewStatus
newUpdateHITReviewStatus Text
pHITId_ =
  UpdateHITReviewStatus' :: Maybe Bool -> Text -> UpdateHITReviewStatus
UpdateHITReviewStatus'
    { $sel:revert:UpdateHITReviewStatus' :: Maybe Bool
revert = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:hITId:UpdateHITReviewStatus' :: Text
hITId = Text
pHITId_
    }

-- | Specifies how to update the HIT status. Default is @False@.
--
-- -   Setting this to false will only transition a HIT from @Reviewable@
--     to @Reviewing@
--
-- -   Setting this to true will only transition a HIT from @Reviewing@ to
--     @Reviewable@
updateHITReviewStatus_revert :: Lens.Lens' UpdateHITReviewStatus (Prelude.Maybe Prelude.Bool)
updateHITReviewStatus_revert :: (Maybe Bool -> f (Maybe Bool))
-> UpdateHITReviewStatus -> f UpdateHITReviewStatus
updateHITReviewStatus_revert = (UpdateHITReviewStatus -> Maybe Bool)
-> (UpdateHITReviewStatus -> Maybe Bool -> UpdateHITReviewStatus)
-> Lens
     UpdateHITReviewStatus
     UpdateHITReviewStatus
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateHITReviewStatus' {Maybe Bool
revert :: Maybe Bool
$sel:revert:UpdateHITReviewStatus' :: UpdateHITReviewStatus -> Maybe Bool
revert} -> Maybe Bool
revert) (\s :: UpdateHITReviewStatus
s@UpdateHITReviewStatus' {} Maybe Bool
a -> UpdateHITReviewStatus
s {$sel:revert:UpdateHITReviewStatus' :: Maybe Bool
revert = Maybe Bool
a} :: UpdateHITReviewStatus)

-- | The ID of the HIT to update.
updateHITReviewStatus_hITId :: Lens.Lens' UpdateHITReviewStatus Prelude.Text
updateHITReviewStatus_hITId :: (Text -> f Text)
-> UpdateHITReviewStatus -> f UpdateHITReviewStatus
updateHITReviewStatus_hITId = (UpdateHITReviewStatus -> Text)
-> (UpdateHITReviewStatus -> Text -> UpdateHITReviewStatus)
-> Lens UpdateHITReviewStatus UpdateHITReviewStatus Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateHITReviewStatus' {Text
hITId :: Text
$sel:hITId:UpdateHITReviewStatus' :: UpdateHITReviewStatus -> Text
hITId} -> Text
hITId) (\s :: UpdateHITReviewStatus
s@UpdateHITReviewStatus' {} Text
a -> UpdateHITReviewStatus
s {$sel:hITId:UpdateHITReviewStatus' :: Text
hITId = Text
a} :: UpdateHITReviewStatus)

instance Core.AWSRequest UpdateHITReviewStatus where
  type
    AWSResponse UpdateHITReviewStatus =
      UpdateHITReviewStatusResponse
  request :: UpdateHITReviewStatus -> Request UpdateHITReviewStatus
request = Service -> UpdateHITReviewStatus -> Request UpdateHITReviewStatus
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateHITReviewStatus
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateHITReviewStatus)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse UpdateHITReviewStatus))
-> Logger
-> Service
-> Proxy UpdateHITReviewStatus
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateHITReviewStatus)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> UpdateHITReviewStatusResponse
UpdateHITReviewStatusResponse'
            (Int -> UpdateHITReviewStatusResponse)
-> Either String Int -> Either String UpdateHITReviewStatusResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable UpdateHITReviewStatus

instance Prelude.NFData UpdateHITReviewStatus

instance Core.ToHeaders UpdateHITReviewStatus where
  toHeaders :: UpdateHITReviewStatus -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateHITReviewStatus -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"MTurkRequesterServiceV20170117.UpdateHITReviewStatus" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON UpdateHITReviewStatus where
  toJSON :: UpdateHITReviewStatus -> Value
toJSON UpdateHITReviewStatus' {Maybe Bool
Text
hITId :: Text
revert :: Maybe Bool
$sel:hITId:UpdateHITReviewStatus' :: UpdateHITReviewStatus -> Text
$sel:revert:UpdateHITReviewStatus' :: UpdateHITReviewStatus -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Revert" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
revert,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"HITId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
hITId)
          ]
      )

instance Core.ToPath UpdateHITReviewStatus where
  toPath :: UpdateHITReviewStatus -> ByteString
toPath = ByteString -> UpdateHITReviewStatus -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery UpdateHITReviewStatus where
  toQuery :: UpdateHITReviewStatus -> QueryString
toQuery = QueryString -> UpdateHITReviewStatus -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newUpdateHITReviewStatusResponse' smart constructor.
data UpdateHITReviewStatusResponse = UpdateHITReviewStatusResponse'
  { -- | The response's http status code.
    UpdateHITReviewStatusResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (UpdateHITReviewStatusResponse
-> UpdateHITReviewStatusResponse -> Bool
(UpdateHITReviewStatusResponse
 -> UpdateHITReviewStatusResponse -> Bool)
-> (UpdateHITReviewStatusResponse
    -> UpdateHITReviewStatusResponse -> Bool)
-> Eq UpdateHITReviewStatusResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateHITReviewStatusResponse
-> UpdateHITReviewStatusResponse -> Bool
$c/= :: UpdateHITReviewStatusResponse
-> UpdateHITReviewStatusResponse -> Bool
== :: UpdateHITReviewStatusResponse
-> UpdateHITReviewStatusResponse -> Bool
$c== :: UpdateHITReviewStatusResponse
-> UpdateHITReviewStatusResponse -> Bool
Prelude.Eq, ReadPrec [UpdateHITReviewStatusResponse]
ReadPrec UpdateHITReviewStatusResponse
Int -> ReadS UpdateHITReviewStatusResponse
ReadS [UpdateHITReviewStatusResponse]
(Int -> ReadS UpdateHITReviewStatusResponse)
-> ReadS [UpdateHITReviewStatusResponse]
-> ReadPrec UpdateHITReviewStatusResponse
-> ReadPrec [UpdateHITReviewStatusResponse]
-> Read UpdateHITReviewStatusResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateHITReviewStatusResponse]
$creadListPrec :: ReadPrec [UpdateHITReviewStatusResponse]
readPrec :: ReadPrec UpdateHITReviewStatusResponse
$creadPrec :: ReadPrec UpdateHITReviewStatusResponse
readList :: ReadS [UpdateHITReviewStatusResponse]
$creadList :: ReadS [UpdateHITReviewStatusResponse]
readsPrec :: Int -> ReadS UpdateHITReviewStatusResponse
$creadsPrec :: Int -> ReadS UpdateHITReviewStatusResponse
Prelude.Read, Int -> UpdateHITReviewStatusResponse -> ShowS
[UpdateHITReviewStatusResponse] -> ShowS
UpdateHITReviewStatusResponse -> String
(Int -> UpdateHITReviewStatusResponse -> ShowS)
-> (UpdateHITReviewStatusResponse -> String)
-> ([UpdateHITReviewStatusResponse] -> ShowS)
-> Show UpdateHITReviewStatusResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateHITReviewStatusResponse] -> ShowS
$cshowList :: [UpdateHITReviewStatusResponse] -> ShowS
show :: UpdateHITReviewStatusResponse -> String
$cshow :: UpdateHITReviewStatusResponse -> String
showsPrec :: Int -> UpdateHITReviewStatusResponse -> ShowS
$cshowsPrec :: Int -> UpdateHITReviewStatusResponse -> ShowS
Prelude.Show, (forall x.
 UpdateHITReviewStatusResponse
 -> Rep UpdateHITReviewStatusResponse x)
-> (forall x.
    Rep UpdateHITReviewStatusResponse x
    -> UpdateHITReviewStatusResponse)
-> Generic UpdateHITReviewStatusResponse
forall x.
Rep UpdateHITReviewStatusResponse x
-> UpdateHITReviewStatusResponse
forall x.
UpdateHITReviewStatusResponse
-> Rep UpdateHITReviewStatusResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateHITReviewStatusResponse x
-> UpdateHITReviewStatusResponse
$cfrom :: forall x.
UpdateHITReviewStatusResponse
-> Rep UpdateHITReviewStatusResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateHITReviewStatusResponse' 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:
--
-- 'httpStatus', 'updateHITReviewStatusResponse_httpStatus' - The response's http status code.
newUpdateHITReviewStatusResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateHITReviewStatusResponse
newUpdateHITReviewStatusResponse :: Int -> UpdateHITReviewStatusResponse
newUpdateHITReviewStatusResponse Int
pHttpStatus_ =
  UpdateHITReviewStatusResponse' :: Int -> UpdateHITReviewStatusResponse
UpdateHITReviewStatusResponse'
    { $sel:httpStatus:UpdateHITReviewStatusResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
updateHITReviewStatusResponse_httpStatus :: Lens.Lens' UpdateHITReviewStatusResponse Prelude.Int
updateHITReviewStatusResponse_httpStatus :: (Int -> f Int)
-> UpdateHITReviewStatusResponse -> f UpdateHITReviewStatusResponse
updateHITReviewStatusResponse_httpStatus = (UpdateHITReviewStatusResponse -> Int)
-> (UpdateHITReviewStatusResponse
    -> Int -> UpdateHITReviewStatusResponse)
-> Lens
     UpdateHITReviewStatusResponse UpdateHITReviewStatusResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateHITReviewStatusResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateHITReviewStatusResponse' :: UpdateHITReviewStatusResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: UpdateHITReviewStatusResponse
s@UpdateHITReviewStatusResponse' {} Int
a -> UpdateHITReviewStatusResponse
s {$sel:httpStatus:UpdateHITReviewStatusResponse' :: Int
httpStatus = Int
a} :: UpdateHITReviewStatusResponse)

instance Prelude.NFData UpdateHITReviewStatusResponse