{-# 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.UpdateHITTypeOfHIT
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- The @UpdateHITTypeOfHIT@ operation allows you to change the HITType
-- properties of a HIT. This operation disassociates the HIT from its old
-- HITType properties and associates it with the new HITType properties.
-- The HIT takes on the properties of the new HITType in place of the old
-- ones.
module Amazonka.MechanicalTurk.UpdateHITTypeOfHIT
  ( -- * Creating a Request
    UpdateHITTypeOfHIT (..),
    newUpdateHITTypeOfHIT,

    -- * Request Lenses
    updateHITTypeOfHIT_hITId,
    updateHITTypeOfHIT_hITTypeId,

    -- * Destructuring the Response
    UpdateHITTypeOfHITResponse (..),
    newUpdateHITTypeOfHITResponse,

    -- * Response Lenses
    updateHITTypeOfHITResponse_httpStatus,
  )
where

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

-- | /See:/ 'newUpdateHITTypeOfHIT' smart constructor.
data UpdateHITTypeOfHIT = UpdateHITTypeOfHIT'
  { -- | The HIT to update.
    UpdateHITTypeOfHIT -> Text
hITId :: Prelude.Text,
    -- | The ID of the new HIT type.
    UpdateHITTypeOfHIT -> Text
hITTypeId :: Prelude.Text
  }
  deriving (UpdateHITTypeOfHIT -> UpdateHITTypeOfHIT -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateHITTypeOfHIT -> UpdateHITTypeOfHIT -> Bool
$c/= :: UpdateHITTypeOfHIT -> UpdateHITTypeOfHIT -> Bool
== :: UpdateHITTypeOfHIT -> UpdateHITTypeOfHIT -> Bool
$c== :: UpdateHITTypeOfHIT -> UpdateHITTypeOfHIT -> Bool
Prelude.Eq, ReadPrec [UpdateHITTypeOfHIT]
ReadPrec UpdateHITTypeOfHIT
Int -> ReadS UpdateHITTypeOfHIT
ReadS [UpdateHITTypeOfHIT]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateHITTypeOfHIT]
$creadListPrec :: ReadPrec [UpdateHITTypeOfHIT]
readPrec :: ReadPrec UpdateHITTypeOfHIT
$creadPrec :: ReadPrec UpdateHITTypeOfHIT
readList :: ReadS [UpdateHITTypeOfHIT]
$creadList :: ReadS [UpdateHITTypeOfHIT]
readsPrec :: Int -> ReadS UpdateHITTypeOfHIT
$creadsPrec :: Int -> ReadS UpdateHITTypeOfHIT
Prelude.Read, Int -> UpdateHITTypeOfHIT -> ShowS
[UpdateHITTypeOfHIT] -> ShowS
UpdateHITTypeOfHIT -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateHITTypeOfHIT] -> ShowS
$cshowList :: [UpdateHITTypeOfHIT] -> ShowS
show :: UpdateHITTypeOfHIT -> String
$cshow :: UpdateHITTypeOfHIT -> String
showsPrec :: Int -> UpdateHITTypeOfHIT -> ShowS
$cshowsPrec :: Int -> UpdateHITTypeOfHIT -> ShowS
Prelude.Show, forall x. Rep UpdateHITTypeOfHIT x -> UpdateHITTypeOfHIT
forall x. UpdateHITTypeOfHIT -> Rep UpdateHITTypeOfHIT x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateHITTypeOfHIT x -> UpdateHITTypeOfHIT
$cfrom :: forall x. UpdateHITTypeOfHIT -> Rep UpdateHITTypeOfHIT x
Prelude.Generic)

-- |
-- Create a value of 'UpdateHITTypeOfHIT' 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', 'updateHITTypeOfHIT_hITId' - The HIT to update.
--
-- 'hITTypeId', 'updateHITTypeOfHIT_hITTypeId' - The ID of the new HIT type.
newUpdateHITTypeOfHIT ::
  -- | 'hITId'
  Prelude.Text ->
  -- | 'hITTypeId'
  Prelude.Text ->
  UpdateHITTypeOfHIT
newUpdateHITTypeOfHIT :: Text -> Text -> UpdateHITTypeOfHIT
newUpdateHITTypeOfHIT Text
pHITId_ Text
pHITTypeId_ =
  UpdateHITTypeOfHIT'
    { $sel:hITId:UpdateHITTypeOfHIT' :: Text
hITId = Text
pHITId_,
      $sel:hITTypeId:UpdateHITTypeOfHIT' :: Text
hITTypeId = Text
pHITTypeId_
    }

-- | The HIT to update.
updateHITTypeOfHIT_hITId :: Lens.Lens' UpdateHITTypeOfHIT Prelude.Text
updateHITTypeOfHIT_hITId :: Lens' UpdateHITTypeOfHIT Text
updateHITTypeOfHIT_hITId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateHITTypeOfHIT' {Text
hITId :: Text
$sel:hITId:UpdateHITTypeOfHIT' :: UpdateHITTypeOfHIT -> Text
hITId} -> Text
hITId) (\s :: UpdateHITTypeOfHIT
s@UpdateHITTypeOfHIT' {} Text
a -> UpdateHITTypeOfHIT
s {$sel:hITId:UpdateHITTypeOfHIT' :: Text
hITId = Text
a} :: UpdateHITTypeOfHIT)

-- | The ID of the new HIT type.
updateHITTypeOfHIT_hITTypeId :: Lens.Lens' UpdateHITTypeOfHIT Prelude.Text
updateHITTypeOfHIT_hITTypeId :: Lens' UpdateHITTypeOfHIT Text
updateHITTypeOfHIT_hITTypeId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateHITTypeOfHIT' {Text
hITTypeId :: Text
$sel:hITTypeId:UpdateHITTypeOfHIT' :: UpdateHITTypeOfHIT -> Text
hITTypeId} -> Text
hITTypeId) (\s :: UpdateHITTypeOfHIT
s@UpdateHITTypeOfHIT' {} Text
a -> UpdateHITTypeOfHIT
s {$sel:hITTypeId:UpdateHITTypeOfHIT' :: Text
hITTypeId = Text
a} :: UpdateHITTypeOfHIT)

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

instance Prelude.Hashable UpdateHITTypeOfHIT where
  hashWithSalt :: Int -> UpdateHITTypeOfHIT -> Int
hashWithSalt Int
_salt UpdateHITTypeOfHIT' {Text
hITTypeId :: Text
hITId :: Text
$sel:hITTypeId:UpdateHITTypeOfHIT' :: UpdateHITTypeOfHIT -> Text
$sel:hITId:UpdateHITTypeOfHIT' :: UpdateHITTypeOfHIT -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
hITId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
hITTypeId

instance Prelude.NFData UpdateHITTypeOfHIT where
  rnf :: UpdateHITTypeOfHIT -> ()
rnf UpdateHITTypeOfHIT' {Text
hITTypeId :: Text
hITId :: Text
$sel:hITTypeId:UpdateHITTypeOfHIT' :: UpdateHITTypeOfHIT -> Text
$sel:hITId:UpdateHITTypeOfHIT' :: UpdateHITTypeOfHIT -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
hITId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
hITTypeId

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

instance Data.ToJSON UpdateHITTypeOfHIT where
  toJSON :: UpdateHITTypeOfHIT -> Value
toJSON UpdateHITTypeOfHIT' {Text
hITTypeId :: Text
hITId :: Text
$sel:hITTypeId:UpdateHITTypeOfHIT' :: UpdateHITTypeOfHIT -> Text
$sel:hITId:UpdateHITTypeOfHIT' :: UpdateHITTypeOfHIT -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"HITId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
hITId),
            forall a. a -> Maybe a
Prelude.Just (Key
"HITTypeId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
hITTypeId)
          ]
      )

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

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

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

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

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

instance Prelude.NFData UpdateHITTypeOfHITResponse where
  rnf :: UpdateHITTypeOfHITResponse -> ()
rnf UpdateHITTypeOfHITResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateHITTypeOfHITResponse' :: UpdateHITTypeOfHITResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus