{-# 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-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 @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.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:/ '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
(UpdateHITTypeOfHIT -> UpdateHITTypeOfHIT -> Bool)
-> (UpdateHITTypeOfHIT -> UpdateHITTypeOfHIT -> Bool)
-> Eq UpdateHITTypeOfHIT
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]
(Int -> ReadS UpdateHITTypeOfHIT)
-> ReadS [UpdateHITTypeOfHIT]
-> ReadPrec UpdateHITTypeOfHIT
-> ReadPrec [UpdateHITTypeOfHIT]
-> Read 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
(Int -> UpdateHITTypeOfHIT -> ShowS)
-> (UpdateHITTypeOfHIT -> String)
-> ([UpdateHITTypeOfHIT] -> ShowS)
-> Show UpdateHITTypeOfHIT
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. UpdateHITTypeOfHIT -> Rep UpdateHITTypeOfHIT x)
-> (forall x. Rep UpdateHITTypeOfHIT x -> UpdateHITTypeOfHIT)
-> Generic UpdateHITTypeOfHIT
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' :: Text -> Text -> UpdateHITTypeOfHIT
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 :: (Text -> f Text) -> UpdateHITTypeOfHIT -> f UpdateHITTypeOfHIT
updateHITTypeOfHIT_hITId = (UpdateHITTypeOfHIT -> Text)
-> (UpdateHITTypeOfHIT -> Text -> UpdateHITTypeOfHIT)
-> Lens UpdateHITTypeOfHIT UpdateHITTypeOfHIT Text Text
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 :: (Text -> f Text) -> UpdateHITTypeOfHIT -> f UpdateHITTypeOfHIT
updateHITTypeOfHIT_hITTypeId = (UpdateHITTypeOfHIT -> Text)
-> (UpdateHITTypeOfHIT -> Text -> UpdateHITTypeOfHIT)
-> Lens UpdateHITTypeOfHIT UpdateHITTypeOfHIT Text Text
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 :: UpdateHITTypeOfHIT -> Request UpdateHITTypeOfHIT
request = Service -> UpdateHITTypeOfHIT -> Request UpdateHITTypeOfHIT
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateHITTypeOfHIT
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateHITTypeOfHIT)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse UpdateHITTypeOfHIT))
-> Logger
-> Service
-> Proxy UpdateHITTypeOfHIT
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateHITTypeOfHIT)))
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 -> UpdateHITTypeOfHITResponse
UpdateHITTypeOfHITResponse'
            (Int -> UpdateHITTypeOfHITResponse)
-> Either String Int -> Either String UpdateHITTypeOfHITResponse
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 UpdateHITTypeOfHIT

instance Prelude.NFData UpdateHITTypeOfHIT

instance Core.ToHeaders UpdateHITTypeOfHIT where
  toHeaders :: UpdateHITTypeOfHIT -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateHITTypeOfHIT -> 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.UpdateHITTypeOfHIT" ::
                          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 UpdateHITTypeOfHIT where
  toJSON :: UpdateHITTypeOfHIT -> Value
toJSON UpdateHITTypeOfHIT' {Text
hITTypeId :: Text
hITId :: Text
$sel:hITTypeId:UpdateHITTypeOfHIT' :: UpdateHITTypeOfHIT -> Text
$sel:hITId:UpdateHITTypeOfHIT' :: UpdateHITTypeOfHIT -> 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),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"HITTypeId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
hITTypeId)
          ]
      )

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

instance Core.ToQuery UpdateHITTypeOfHIT where
  toQuery :: UpdateHITTypeOfHIT -> QueryString
toQuery = QueryString -> UpdateHITTypeOfHIT -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(UpdateHITTypeOfHITResponse -> UpdateHITTypeOfHITResponse -> Bool)
-> (UpdateHITTypeOfHITResponse
    -> UpdateHITTypeOfHITResponse -> Bool)
-> Eq UpdateHITTypeOfHITResponse
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]
(Int -> ReadS UpdateHITTypeOfHITResponse)
-> ReadS [UpdateHITTypeOfHITResponse]
-> ReadPrec UpdateHITTypeOfHITResponse
-> ReadPrec [UpdateHITTypeOfHITResponse]
-> Read 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
(Int -> UpdateHITTypeOfHITResponse -> ShowS)
-> (UpdateHITTypeOfHITResponse -> String)
-> ([UpdateHITTypeOfHITResponse] -> ShowS)
-> Show UpdateHITTypeOfHITResponse
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.
 UpdateHITTypeOfHITResponse -> Rep UpdateHITTypeOfHITResponse x)
-> (forall x.
    Rep UpdateHITTypeOfHITResponse x -> UpdateHITTypeOfHITResponse)
-> Generic UpdateHITTypeOfHITResponse
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' :: Int -> UpdateHITTypeOfHITResponse
UpdateHITTypeOfHITResponse'
    { $sel:httpStatus:UpdateHITTypeOfHITResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
updateHITTypeOfHITResponse_httpStatus :: Lens.Lens' UpdateHITTypeOfHITResponse Prelude.Int
updateHITTypeOfHITResponse_httpStatus :: (Int -> f Int)
-> UpdateHITTypeOfHITResponse -> f UpdateHITTypeOfHITResponse
updateHITTypeOfHITResponse_httpStatus = (UpdateHITTypeOfHITResponse -> Int)
-> (UpdateHITTypeOfHITResponse
    -> Int -> UpdateHITTypeOfHITResponse)
-> Lens
     UpdateHITTypeOfHITResponse UpdateHITTypeOfHITResponse Int Int
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