{-# 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.DeleteWorkerBlock
-- 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 @DeleteWorkerBlock@ operation allows you to reinstate a blocked
-- Worker to work on your HITs. This operation reverses the effects of the
-- CreateWorkerBlock operation. You need the Worker ID to use this
-- operation. If the Worker ID is missing or invalid, this operation fails
-- and returns the message “WorkerId is invalid.” If the specified Worker
-- is not blocked, this operation returns successfully.
module Amazonka.MechanicalTurk.DeleteWorkerBlock
  ( -- * Creating a Request
    DeleteWorkerBlock (..),
    newDeleteWorkerBlock,

    -- * Request Lenses
    deleteWorkerBlock_reason,
    deleteWorkerBlock_workerId,

    -- * Destructuring the Response
    DeleteWorkerBlockResponse (..),
    newDeleteWorkerBlockResponse,

    -- * Response Lenses
    deleteWorkerBlockResponse_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:/ 'newDeleteWorkerBlock' smart constructor.
data DeleteWorkerBlock = DeleteWorkerBlock'
  { -- | A message that explains the reason for unblocking the Worker. The Worker
    -- does not see this message.
    DeleteWorkerBlock -> Maybe Text
reason :: Prelude.Maybe Prelude.Text,
    -- | The ID of the Worker to unblock.
    DeleteWorkerBlock -> Text
workerId :: Prelude.Text
  }
  deriving (DeleteWorkerBlock -> DeleteWorkerBlock -> Bool
(DeleteWorkerBlock -> DeleteWorkerBlock -> Bool)
-> (DeleteWorkerBlock -> DeleteWorkerBlock -> Bool)
-> Eq DeleteWorkerBlock
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteWorkerBlock -> DeleteWorkerBlock -> Bool
$c/= :: DeleteWorkerBlock -> DeleteWorkerBlock -> Bool
== :: DeleteWorkerBlock -> DeleteWorkerBlock -> Bool
$c== :: DeleteWorkerBlock -> DeleteWorkerBlock -> Bool
Prelude.Eq, ReadPrec [DeleteWorkerBlock]
ReadPrec DeleteWorkerBlock
Int -> ReadS DeleteWorkerBlock
ReadS [DeleteWorkerBlock]
(Int -> ReadS DeleteWorkerBlock)
-> ReadS [DeleteWorkerBlock]
-> ReadPrec DeleteWorkerBlock
-> ReadPrec [DeleteWorkerBlock]
-> Read DeleteWorkerBlock
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteWorkerBlock]
$creadListPrec :: ReadPrec [DeleteWorkerBlock]
readPrec :: ReadPrec DeleteWorkerBlock
$creadPrec :: ReadPrec DeleteWorkerBlock
readList :: ReadS [DeleteWorkerBlock]
$creadList :: ReadS [DeleteWorkerBlock]
readsPrec :: Int -> ReadS DeleteWorkerBlock
$creadsPrec :: Int -> ReadS DeleteWorkerBlock
Prelude.Read, Int -> DeleteWorkerBlock -> ShowS
[DeleteWorkerBlock] -> ShowS
DeleteWorkerBlock -> String
(Int -> DeleteWorkerBlock -> ShowS)
-> (DeleteWorkerBlock -> String)
-> ([DeleteWorkerBlock] -> ShowS)
-> Show DeleteWorkerBlock
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteWorkerBlock] -> ShowS
$cshowList :: [DeleteWorkerBlock] -> ShowS
show :: DeleteWorkerBlock -> String
$cshow :: DeleteWorkerBlock -> String
showsPrec :: Int -> DeleteWorkerBlock -> ShowS
$cshowsPrec :: Int -> DeleteWorkerBlock -> ShowS
Prelude.Show, (forall x. DeleteWorkerBlock -> Rep DeleteWorkerBlock x)
-> (forall x. Rep DeleteWorkerBlock x -> DeleteWorkerBlock)
-> Generic DeleteWorkerBlock
forall x. Rep DeleteWorkerBlock x -> DeleteWorkerBlock
forall x. DeleteWorkerBlock -> Rep DeleteWorkerBlock x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteWorkerBlock x -> DeleteWorkerBlock
$cfrom :: forall x. DeleteWorkerBlock -> Rep DeleteWorkerBlock x
Prelude.Generic)

-- |
-- Create a value of 'DeleteWorkerBlock' 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', 'deleteWorkerBlock_reason' - A message that explains the reason for unblocking the Worker. The Worker
-- does not see this message.
--
-- 'workerId', 'deleteWorkerBlock_workerId' - The ID of the Worker to unblock.
newDeleteWorkerBlock ::
  -- | 'workerId'
  Prelude.Text ->
  DeleteWorkerBlock
newDeleteWorkerBlock :: Text -> DeleteWorkerBlock
newDeleteWorkerBlock Text
pWorkerId_ =
  DeleteWorkerBlock' :: Maybe Text -> Text -> DeleteWorkerBlock
DeleteWorkerBlock'
    { $sel:reason:DeleteWorkerBlock' :: Maybe Text
reason = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:workerId:DeleteWorkerBlock' :: Text
workerId = Text
pWorkerId_
    }

-- | A message that explains the reason for unblocking the Worker. The Worker
-- does not see this message.
deleteWorkerBlock_reason :: Lens.Lens' DeleteWorkerBlock (Prelude.Maybe Prelude.Text)
deleteWorkerBlock_reason :: (Maybe Text -> f (Maybe Text))
-> DeleteWorkerBlock -> f DeleteWorkerBlock
deleteWorkerBlock_reason = (DeleteWorkerBlock -> Maybe Text)
-> (DeleteWorkerBlock -> Maybe Text -> DeleteWorkerBlock)
-> Lens
     DeleteWorkerBlock DeleteWorkerBlock (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteWorkerBlock' {Maybe Text
reason :: Maybe Text
$sel:reason:DeleteWorkerBlock' :: DeleteWorkerBlock -> Maybe Text
reason} -> Maybe Text
reason) (\s :: DeleteWorkerBlock
s@DeleteWorkerBlock' {} Maybe Text
a -> DeleteWorkerBlock
s {$sel:reason:DeleteWorkerBlock' :: Maybe Text
reason = Maybe Text
a} :: DeleteWorkerBlock)

-- | The ID of the Worker to unblock.
deleteWorkerBlock_workerId :: Lens.Lens' DeleteWorkerBlock Prelude.Text
deleteWorkerBlock_workerId :: (Text -> f Text) -> DeleteWorkerBlock -> f DeleteWorkerBlock
deleteWorkerBlock_workerId = (DeleteWorkerBlock -> Text)
-> (DeleteWorkerBlock -> Text -> DeleteWorkerBlock)
-> Lens DeleteWorkerBlock DeleteWorkerBlock Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteWorkerBlock' {Text
workerId :: Text
$sel:workerId:DeleteWorkerBlock' :: DeleteWorkerBlock -> Text
workerId} -> Text
workerId) (\s :: DeleteWorkerBlock
s@DeleteWorkerBlock' {} Text
a -> DeleteWorkerBlock
s {$sel:workerId:DeleteWorkerBlock' :: Text
workerId = Text
a} :: DeleteWorkerBlock)

instance Core.AWSRequest DeleteWorkerBlock where
  type
    AWSResponse DeleteWorkerBlock =
      DeleteWorkerBlockResponse
  request :: DeleteWorkerBlock -> Request DeleteWorkerBlock
request = Service -> DeleteWorkerBlock -> Request DeleteWorkerBlock
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteWorkerBlock
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteWorkerBlock)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteWorkerBlock))
-> Logger
-> Service
-> Proxy DeleteWorkerBlock
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteWorkerBlock)))
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 -> DeleteWorkerBlockResponse
DeleteWorkerBlockResponse'
            (Int -> DeleteWorkerBlockResponse)
-> Either String Int -> Either String DeleteWorkerBlockResponse
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 DeleteWorkerBlock

instance Prelude.NFData DeleteWorkerBlock

instance Core.ToHeaders DeleteWorkerBlock where
  toHeaders :: DeleteWorkerBlock -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteWorkerBlock -> 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.DeleteWorkerBlock" ::
                          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 DeleteWorkerBlock where
  toJSON :: DeleteWorkerBlock -> Value
toJSON DeleteWorkerBlock' {Maybe Text
Text
workerId :: Text
reason :: Maybe Text
$sel:workerId:DeleteWorkerBlock' :: DeleteWorkerBlock -> Text
$sel:reason:DeleteWorkerBlock' :: DeleteWorkerBlock -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Reason" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
reason,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"WorkerId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
workerId)
          ]
      )

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

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

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

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

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

instance Prelude.NFData DeleteWorkerBlockResponse