{-# 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 #-}
module Amazonka.MechanicalTurk.GetFileUploadURL
(
GetFileUploadURL (..),
newGetFileUploadURL,
getFileUploadURL_assignmentId,
getFileUploadURL_questionIdentifier,
GetFileUploadURLResponse (..),
newGetFileUploadURLResponse,
getFileUploadURLResponse_fileUploadURL,
getFileUploadURLResponse_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
data GetFileUploadURL = GetFileUploadURL'
{
GetFileUploadURL -> Text
assignmentId :: Prelude.Text,
GetFileUploadURL -> Text
questionIdentifier :: Prelude.Text
}
deriving (GetFileUploadURL -> GetFileUploadURL -> Bool
(GetFileUploadURL -> GetFileUploadURL -> Bool)
-> (GetFileUploadURL -> GetFileUploadURL -> Bool)
-> Eq GetFileUploadURL
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetFileUploadURL -> GetFileUploadURL -> Bool
$c/= :: GetFileUploadURL -> GetFileUploadURL -> Bool
== :: GetFileUploadURL -> GetFileUploadURL -> Bool
$c== :: GetFileUploadURL -> GetFileUploadURL -> Bool
Prelude.Eq, ReadPrec [GetFileUploadURL]
ReadPrec GetFileUploadURL
Int -> ReadS GetFileUploadURL
ReadS [GetFileUploadURL]
(Int -> ReadS GetFileUploadURL)
-> ReadS [GetFileUploadURL]
-> ReadPrec GetFileUploadURL
-> ReadPrec [GetFileUploadURL]
-> Read GetFileUploadURL
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetFileUploadURL]
$creadListPrec :: ReadPrec [GetFileUploadURL]
readPrec :: ReadPrec GetFileUploadURL
$creadPrec :: ReadPrec GetFileUploadURL
readList :: ReadS [GetFileUploadURL]
$creadList :: ReadS [GetFileUploadURL]
readsPrec :: Int -> ReadS GetFileUploadURL
$creadsPrec :: Int -> ReadS GetFileUploadURL
Prelude.Read, Int -> GetFileUploadURL -> ShowS
[GetFileUploadURL] -> ShowS
GetFileUploadURL -> String
(Int -> GetFileUploadURL -> ShowS)
-> (GetFileUploadURL -> String)
-> ([GetFileUploadURL] -> ShowS)
-> Show GetFileUploadURL
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetFileUploadURL] -> ShowS
$cshowList :: [GetFileUploadURL] -> ShowS
show :: GetFileUploadURL -> String
$cshow :: GetFileUploadURL -> String
showsPrec :: Int -> GetFileUploadURL -> ShowS
$cshowsPrec :: Int -> GetFileUploadURL -> ShowS
Prelude.Show, (forall x. GetFileUploadURL -> Rep GetFileUploadURL x)
-> (forall x. Rep GetFileUploadURL x -> GetFileUploadURL)
-> Generic GetFileUploadURL
forall x. Rep GetFileUploadURL x -> GetFileUploadURL
forall x. GetFileUploadURL -> Rep GetFileUploadURL x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetFileUploadURL x -> GetFileUploadURL
$cfrom :: forall x. GetFileUploadURL -> Rep GetFileUploadURL x
Prelude.Generic)
newGetFileUploadURL ::
Prelude.Text ->
Prelude.Text ->
GetFileUploadURL
newGetFileUploadURL :: Text -> Text -> GetFileUploadURL
newGetFileUploadURL
Text
pAssignmentId_
Text
pQuestionIdentifier_ =
GetFileUploadURL' :: Text -> Text -> GetFileUploadURL
GetFileUploadURL'
{ $sel:assignmentId:GetFileUploadURL' :: Text
assignmentId = Text
pAssignmentId_,
$sel:questionIdentifier:GetFileUploadURL' :: Text
questionIdentifier = Text
pQuestionIdentifier_
}
getFileUploadURL_assignmentId :: Lens.Lens' GetFileUploadURL Prelude.Text
getFileUploadURL_assignmentId :: (Text -> f Text) -> GetFileUploadURL -> f GetFileUploadURL
getFileUploadURL_assignmentId = (GetFileUploadURL -> Text)
-> (GetFileUploadURL -> Text -> GetFileUploadURL)
-> Lens GetFileUploadURL GetFileUploadURL Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetFileUploadURL' {Text
assignmentId :: Text
$sel:assignmentId:GetFileUploadURL' :: GetFileUploadURL -> Text
assignmentId} -> Text
assignmentId) (\s :: GetFileUploadURL
s@GetFileUploadURL' {} Text
a -> GetFileUploadURL
s {$sel:assignmentId:GetFileUploadURL' :: Text
assignmentId = Text
a} :: GetFileUploadURL)
getFileUploadURL_questionIdentifier :: Lens.Lens' GetFileUploadURL Prelude.Text
getFileUploadURL_questionIdentifier :: (Text -> f Text) -> GetFileUploadURL -> f GetFileUploadURL
getFileUploadURL_questionIdentifier = (GetFileUploadURL -> Text)
-> (GetFileUploadURL -> Text -> GetFileUploadURL)
-> Lens GetFileUploadURL GetFileUploadURL Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetFileUploadURL' {Text
questionIdentifier :: Text
$sel:questionIdentifier:GetFileUploadURL' :: GetFileUploadURL -> Text
questionIdentifier} -> Text
questionIdentifier) (\s :: GetFileUploadURL
s@GetFileUploadURL' {} Text
a -> GetFileUploadURL
s {$sel:questionIdentifier:GetFileUploadURL' :: Text
questionIdentifier = Text
a} :: GetFileUploadURL)
instance Core.AWSRequest GetFileUploadURL where
type
AWSResponse GetFileUploadURL =
GetFileUploadURLResponse
request :: GetFileUploadURL -> Request GetFileUploadURL
request = Service -> GetFileUploadURL -> Request GetFileUploadURL
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy GetFileUploadURL
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetFileUploadURL)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse GetFileUploadURL))
-> Logger
-> Service
-> Proxy GetFileUploadURL
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetFileUploadURL)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
( \Int
s ResponseHeaders
h Object
x ->
Maybe Text -> Int -> GetFileUploadURLResponse
GetFileUploadURLResponse'
(Maybe Text -> Int -> GetFileUploadURLResponse)
-> Either String (Maybe Text)
-> Either String (Int -> GetFileUploadURLResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"FileUploadURL")
Either String (Int -> GetFileUploadURLResponse)
-> Either String Int -> Either String GetFileUploadURLResponse
forall (f :: * -> *) a b. Applicative f => 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 GetFileUploadURL
instance Prelude.NFData GetFileUploadURL
instance Core.ToHeaders GetFileUploadURL where
toHeaders :: GetFileUploadURL -> ResponseHeaders
toHeaders =
ResponseHeaders -> GetFileUploadURL -> 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.GetFileUploadURL" ::
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 GetFileUploadURL where
toJSON :: GetFileUploadURL -> Value
toJSON GetFileUploadURL' {Text
questionIdentifier :: Text
assignmentId :: Text
$sel:questionIdentifier:GetFileUploadURL' :: GetFileUploadURL -> Text
$sel:assignmentId:GetFileUploadURL' :: GetFileUploadURL -> 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
"AssignmentId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
assignmentId),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"QuestionIdentifier" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
questionIdentifier)
]
)
instance Core.ToPath GetFileUploadURL where
toPath :: GetFileUploadURL -> ByteString
toPath = ByteString -> GetFileUploadURL -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery GetFileUploadURL where
toQuery :: GetFileUploadURL -> QueryString
toQuery = QueryString -> GetFileUploadURL -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data GetFileUploadURLResponse = GetFileUploadURLResponse'
{
GetFileUploadURLResponse -> Maybe Text
fileUploadURL :: Prelude.Maybe Prelude.Text,
GetFileUploadURLResponse -> Int
httpStatus :: Prelude.Int
}
deriving (GetFileUploadURLResponse -> GetFileUploadURLResponse -> Bool
(GetFileUploadURLResponse -> GetFileUploadURLResponse -> Bool)
-> (GetFileUploadURLResponse -> GetFileUploadURLResponse -> Bool)
-> Eq GetFileUploadURLResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetFileUploadURLResponse -> GetFileUploadURLResponse -> Bool
$c/= :: GetFileUploadURLResponse -> GetFileUploadURLResponse -> Bool
== :: GetFileUploadURLResponse -> GetFileUploadURLResponse -> Bool
$c== :: GetFileUploadURLResponse -> GetFileUploadURLResponse -> Bool
Prelude.Eq, ReadPrec [GetFileUploadURLResponse]
ReadPrec GetFileUploadURLResponse
Int -> ReadS GetFileUploadURLResponse
ReadS [GetFileUploadURLResponse]
(Int -> ReadS GetFileUploadURLResponse)
-> ReadS [GetFileUploadURLResponse]
-> ReadPrec GetFileUploadURLResponse
-> ReadPrec [GetFileUploadURLResponse]
-> Read GetFileUploadURLResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetFileUploadURLResponse]
$creadListPrec :: ReadPrec [GetFileUploadURLResponse]
readPrec :: ReadPrec GetFileUploadURLResponse
$creadPrec :: ReadPrec GetFileUploadURLResponse
readList :: ReadS [GetFileUploadURLResponse]
$creadList :: ReadS [GetFileUploadURLResponse]
readsPrec :: Int -> ReadS GetFileUploadURLResponse
$creadsPrec :: Int -> ReadS GetFileUploadURLResponse
Prelude.Read, Int -> GetFileUploadURLResponse -> ShowS
[GetFileUploadURLResponse] -> ShowS
GetFileUploadURLResponse -> String
(Int -> GetFileUploadURLResponse -> ShowS)
-> (GetFileUploadURLResponse -> String)
-> ([GetFileUploadURLResponse] -> ShowS)
-> Show GetFileUploadURLResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetFileUploadURLResponse] -> ShowS
$cshowList :: [GetFileUploadURLResponse] -> ShowS
show :: GetFileUploadURLResponse -> String
$cshow :: GetFileUploadURLResponse -> String
showsPrec :: Int -> GetFileUploadURLResponse -> ShowS
$cshowsPrec :: Int -> GetFileUploadURLResponse -> ShowS
Prelude.Show, (forall x.
GetFileUploadURLResponse -> Rep GetFileUploadURLResponse x)
-> (forall x.
Rep GetFileUploadURLResponse x -> GetFileUploadURLResponse)
-> Generic GetFileUploadURLResponse
forall x.
Rep GetFileUploadURLResponse x -> GetFileUploadURLResponse
forall x.
GetFileUploadURLResponse -> Rep GetFileUploadURLResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetFileUploadURLResponse x -> GetFileUploadURLResponse
$cfrom :: forall x.
GetFileUploadURLResponse -> Rep GetFileUploadURLResponse x
Prelude.Generic)
newGetFileUploadURLResponse ::
Prelude.Int ->
GetFileUploadURLResponse
newGetFileUploadURLResponse :: Int -> GetFileUploadURLResponse
newGetFileUploadURLResponse Int
pHttpStatus_ =
GetFileUploadURLResponse' :: Maybe Text -> Int -> GetFileUploadURLResponse
GetFileUploadURLResponse'
{ $sel:fileUploadURL:GetFileUploadURLResponse' :: Maybe Text
fileUploadURL =
Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:GetFileUploadURLResponse' :: Int
httpStatus = Int
pHttpStatus_
}
getFileUploadURLResponse_fileUploadURL :: Lens.Lens' GetFileUploadURLResponse (Prelude.Maybe Prelude.Text)
getFileUploadURLResponse_fileUploadURL :: (Maybe Text -> f (Maybe Text))
-> GetFileUploadURLResponse -> f GetFileUploadURLResponse
getFileUploadURLResponse_fileUploadURL = (GetFileUploadURLResponse -> Maybe Text)
-> (GetFileUploadURLResponse
-> Maybe Text -> GetFileUploadURLResponse)
-> Lens
GetFileUploadURLResponse
GetFileUploadURLResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetFileUploadURLResponse' {Maybe Text
fileUploadURL :: Maybe Text
$sel:fileUploadURL:GetFileUploadURLResponse' :: GetFileUploadURLResponse -> Maybe Text
fileUploadURL} -> Maybe Text
fileUploadURL) (\s :: GetFileUploadURLResponse
s@GetFileUploadURLResponse' {} Maybe Text
a -> GetFileUploadURLResponse
s {$sel:fileUploadURL:GetFileUploadURLResponse' :: Maybe Text
fileUploadURL = Maybe Text
a} :: GetFileUploadURLResponse)
getFileUploadURLResponse_httpStatus :: Lens.Lens' GetFileUploadURLResponse Prelude.Int
getFileUploadURLResponse_httpStatus :: (Int -> f Int)
-> GetFileUploadURLResponse -> f GetFileUploadURLResponse
getFileUploadURLResponse_httpStatus = (GetFileUploadURLResponse -> Int)
-> (GetFileUploadURLResponse -> Int -> GetFileUploadURLResponse)
-> Lens GetFileUploadURLResponse GetFileUploadURLResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetFileUploadURLResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetFileUploadURLResponse' :: GetFileUploadURLResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetFileUploadURLResponse
s@GetFileUploadURLResponse' {} Int
a -> GetFileUploadURLResponse
s {$sel:httpStatus:GetFileUploadURLResponse' :: Int
httpStatus = Int
a} :: GetFileUploadURLResponse)
instance Prelude.NFData GetFileUploadURLResponse