{-# 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.DeleteHIT
-- 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 @DeleteHIT@ operation is used to delete HIT that is no longer
-- needed. Only the Requester who created the HIT can delete it.
--
-- You can only dispose of HITs that are in the @Reviewable@ state, with
-- all of their submitted assignments already either approved or rejected.
-- If you call the DeleteHIT operation on a HIT that is not in the
-- @Reviewable@ state (for example, that has not expired, or still has
-- active assignments), or on a HIT that is Reviewable but without all of
-- its submitted assignments already approved or rejected, the service will
-- return an error.
--
-- -   HITs are automatically disposed of after 120 days.
--
-- -   After you dispose of a HIT, you can no longer approve the HIT\'s
--     rejected assignments.
--
-- -   Disposed HITs are not returned in results for the ListHITs
--     operation.
--
-- -   Disposing HITs can improve the performance of operations such as
--     ListReviewableHITs and ListHITs.
module Amazonka.MechanicalTurk.DeleteHIT
  ( -- * Creating a Request
    DeleteHIT (..),
    newDeleteHIT,

    -- * Request Lenses
    deleteHIT_hITId,

    -- * Destructuring the Response
    DeleteHITResponse (..),
    newDeleteHITResponse,

    -- * Response Lenses
    deleteHITResponse_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:/ 'newDeleteHIT' smart constructor.
data DeleteHIT = DeleteHIT'
  { -- | The ID of the HIT to be deleted.
    DeleteHIT -> Text
hITId :: Prelude.Text
  }
  deriving (DeleteHIT -> DeleteHIT -> Bool
(DeleteHIT -> DeleteHIT -> Bool)
-> (DeleteHIT -> DeleteHIT -> Bool) -> Eq DeleteHIT
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteHIT -> DeleteHIT -> Bool
$c/= :: DeleteHIT -> DeleteHIT -> Bool
== :: DeleteHIT -> DeleteHIT -> Bool
$c== :: DeleteHIT -> DeleteHIT -> Bool
Prelude.Eq, ReadPrec [DeleteHIT]
ReadPrec DeleteHIT
Int -> ReadS DeleteHIT
ReadS [DeleteHIT]
(Int -> ReadS DeleteHIT)
-> ReadS [DeleteHIT]
-> ReadPrec DeleteHIT
-> ReadPrec [DeleteHIT]
-> Read DeleteHIT
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteHIT]
$creadListPrec :: ReadPrec [DeleteHIT]
readPrec :: ReadPrec DeleteHIT
$creadPrec :: ReadPrec DeleteHIT
readList :: ReadS [DeleteHIT]
$creadList :: ReadS [DeleteHIT]
readsPrec :: Int -> ReadS DeleteHIT
$creadsPrec :: Int -> ReadS DeleteHIT
Prelude.Read, Int -> DeleteHIT -> ShowS
[DeleteHIT] -> ShowS
DeleteHIT -> String
(Int -> DeleteHIT -> ShowS)
-> (DeleteHIT -> String)
-> ([DeleteHIT] -> ShowS)
-> Show DeleteHIT
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteHIT] -> ShowS
$cshowList :: [DeleteHIT] -> ShowS
show :: DeleteHIT -> String
$cshow :: DeleteHIT -> String
showsPrec :: Int -> DeleteHIT -> ShowS
$cshowsPrec :: Int -> DeleteHIT -> ShowS
Prelude.Show, (forall x. DeleteHIT -> Rep DeleteHIT x)
-> (forall x. Rep DeleteHIT x -> DeleteHIT) -> Generic DeleteHIT
forall x. Rep DeleteHIT x -> DeleteHIT
forall x. DeleteHIT -> Rep DeleteHIT x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteHIT x -> DeleteHIT
$cfrom :: forall x. DeleteHIT -> Rep DeleteHIT x
Prelude.Generic)

-- |
-- Create a value of 'DeleteHIT' 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:
--
-- 'hITId', 'deleteHIT_hITId' - The ID of the HIT to be deleted.
newDeleteHIT ::
  -- | 'hITId'
  Prelude.Text ->
  DeleteHIT
newDeleteHIT :: Text -> DeleteHIT
newDeleteHIT Text
pHITId_ = DeleteHIT' :: Text -> DeleteHIT
DeleteHIT' {$sel:hITId:DeleteHIT' :: Text
hITId = Text
pHITId_}

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

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

instance Prelude.NFData DeleteHIT

instance Core.ToHeaders DeleteHIT where
  toHeaders :: DeleteHIT -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteHIT -> 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.DeleteHIT" ::
                          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 DeleteHIT where
  toJSON :: DeleteHIT -> Value
toJSON DeleteHIT' {Text
hITId :: Text
$sel:hITId:DeleteHIT' :: DeleteHIT -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [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 DeleteHIT where
  toPath :: DeleteHIT -> ByteString
toPath = ByteString -> DeleteHIT -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

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

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

instance Prelude.NFData DeleteHITResponse