{-# 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.DeleteQualificationType
-- 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 @DeleteQualificationType@ deletes a Qualification type and deletes
-- any HIT types that are associated with the Qualification type.
--
-- This operation does not revoke Qualifications already assigned to
-- Workers because the Qualifications might be needed for active HITs. If
-- there are any pending requests for the Qualification type, Amazon
-- Mechanical Turk rejects those requests. After you delete a Qualification
-- type, you can no longer use it to create HITs or HIT types.
--
-- DeleteQualificationType must wait for all the HITs that use the deleted
-- Qualification type to be deleted before completing. It may take up to 48
-- hours before DeleteQualificationType completes and the unique name of
-- the Qualification type is available for reuse with
-- CreateQualificationType.
module Amazonka.MechanicalTurk.DeleteQualificationType
  ( -- * Creating a Request
    DeleteQualificationType (..),
    newDeleteQualificationType,

    -- * Request Lenses
    deleteQualificationType_qualificationTypeId,

    -- * Destructuring the Response
    DeleteQualificationTypeResponse (..),
    newDeleteQualificationTypeResponse,

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

-- |
-- Create a value of 'DeleteQualificationType' 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:
--
-- 'qualificationTypeId', 'deleteQualificationType_qualificationTypeId' - The ID of the QualificationType to dispose.
newDeleteQualificationType ::
  -- | 'qualificationTypeId'
  Prelude.Text ->
  DeleteQualificationType
newDeleteQualificationType :: Text -> DeleteQualificationType
newDeleteQualificationType Text
pQualificationTypeId_ =
  DeleteQualificationType' :: Text -> DeleteQualificationType
DeleteQualificationType'
    { $sel:qualificationTypeId:DeleteQualificationType' :: Text
qualificationTypeId =
        Text
pQualificationTypeId_
    }

-- | The ID of the QualificationType to dispose.
deleteQualificationType_qualificationTypeId :: Lens.Lens' DeleteQualificationType Prelude.Text
deleteQualificationType_qualificationTypeId :: (Text -> f Text)
-> DeleteQualificationType -> f DeleteQualificationType
deleteQualificationType_qualificationTypeId = (DeleteQualificationType -> Text)
-> (DeleteQualificationType -> Text -> DeleteQualificationType)
-> Lens DeleteQualificationType DeleteQualificationType Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteQualificationType' {Text
qualificationTypeId :: Text
$sel:qualificationTypeId:DeleteQualificationType' :: DeleteQualificationType -> Text
qualificationTypeId} -> Text
qualificationTypeId) (\s :: DeleteQualificationType
s@DeleteQualificationType' {} Text
a -> DeleteQualificationType
s {$sel:qualificationTypeId:DeleteQualificationType' :: Text
qualificationTypeId = Text
a} :: DeleteQualificationType)

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

instance Prelude.NFData DeleteQualificationType

instance Core.ToHeaders DeleteQualificationType where
  toHeaders :: DeleteQualificationType -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteQualificationType -> 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.DeleteQualificationType" ::
                          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 DeleteQualificationType where
  toJSON :: DeleteQualificationType -> Value
toJSON DeleteQualificationType' {Text
qualificationTypeId :: Text
$sel:qualificationTypeId:DeleteQualificationType' :: DeleteQualificationType -> 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
"QualificationTypeId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
qualificationTypeId)
          ]
      )

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

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

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

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

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

instance
  Prelude.NFData
    DeleteQualificationTypeResponse