{-# 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.DeviceFarm.CreateUpload
(
CreateUpload (..),
newCreateUpload,
createUpload_contentType,
createUpload_projectArn,
createUpload_name,
createUpload_type,
CreateUploadResponse (..),
newCreateUploadResponse,
createUploadResponse_upload,
createUploadResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.DeviceFarm.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data CreateUpload = CreateUpload'
{
CreateUpload -> Maybe Text
contentType :: Prelude.Maybe Prelude.Text,
CreateUpload -> Text
projectArn :: Prelude.Text,
CreateUpload -> Text
name :: Prelude.Text,
CreateUpload -> UploadType
type' :: UploadType
}
deriving (CreateUpload -> CreateUpload -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateUpload -> CreateUpload -> Bool
$c/= :: CreateUpload -> CreateUpload -> Bool
== :: CreateUpload -> CreateUpload -> Bool
$c== :: CreateUpload -> CreateUpload -> Bool
Prelude.Eq, ReadPrec [CreateUpload]
ReadPrec CreateUpload
Int -> ReadS CreateUpload
ReadS [CreateUpload]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateUpload]
$creadListPrec :: ReadPrec [CreateUpload]
readPrec :: ReadPrec CreateUpload
$creadPrec :: ReadPrec CreateUpload
readList :: ReadS [CreateUpload]
$creadList :: ReadS [CreateUpload]
readsPrec :: Int -> ReadS CreateUpload
$creadsPrec :: Int -> ReadS CreateUpload
Prelude.Read, Int -> CreateUpload -> ShowS
[CreateUpload] -> ShowS
CreateUpload -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateUpload] -> ShowS
$cshowList :: [CreateUpload] -> ShowS
show :: CreateUpload -> String
$cshow :: CreateUpload -> String
showsPrec :: Int -> CreateUpload -> ShowS
$cshowsPrec :: Int -> CreateUpload -> ShowS
Prelude.Show, forall x. Rep CreateUpload x -> CreateUpload
forall x. CreateUpload -> Rep CreateUpload x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateUpload x -> CreateUpload
$cfrom :: forall x. CreateUpload -> Rep CreateUpload x
Prelude.Generic)
newCreateUpload ::
Prelude.Text ->
Prelude.Text ->
UploadType ->
CreateUpload
newCreateUpload :: Text -> Text -> UploadType -> CreateUpload
newCreateUpload Text
pProjectArn_ Text
pName_ UploadType
pType_ =
CreateUpload'
{ $sel:contentType:CreateUpload' :: Maybe Text
contentType = forall a. Maybe a
Prelude.Nothing,
$sel:projectArn:CreateUpload' :: Text
projectArn = Text
pProjectArn_,
$sel:name:CreateUpload' :: Text
name = Text
pName_,
$sel:type':CreateUpload' :: UploadType
type' = UploadType
pType_
}
createUpload_contentType :: Lens.Lens' CreateUpload (Prelude.Maybe Prelude.Text)
createUpload_contentType :: Lens' CreateUpload (Maybe Text)
createUpload_contentType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateUpload' {Maybe Text
contentType :: Maybe Text
$sel:contentType:CreateUpload' :: CreateUpload -> Maybe Text
contentType} -> Maybe Text
contentType) (\s :: CreateUpload
s@CreateUpload' {} Maybe Text
a -> CreateUpload
s {$sel:contentType:CreateUpload' :: Maybe Text
contentType = Maybe Text
a} :: CreateUpload)
createUpload_projectArn :: Lens.Lens' CreateUpload Prelude.Text
createUpload_projectArn :: Lens' CreateUpload Text
createUpload_projectArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateUpload' {Text
projectArn :: Text
$sel:projectArn:CreateUpload' :: CreateUpload -> Text
projectArn} -> Text
projectArn) (\s :: CreateUpload
s@CreateUpload' {} Text
a -> CreateUpload
s {$sel:projectArn:CreateUpload' :: Text
projectArn = Text
a} :: CreateUpload)
createUpload_name :: Lens.Lens' CreateUpload Prelude.Text
createUpload_name :: Lens' CreateUpload Text
createUpload_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateUpload' {Text
name :: Text
$sel:name:CreateUpload' :: CreateUpload -> Text
name} -> Text
name) (\s :: CreateUpload
s@CreateUpload' {} Text
a -> CreateUpload
s {$sel:name:CreateUpload' :: Text
name = Text
a} :: CreateUpload)
createUpload_type :: Lens.Lens' CreateUpload UploadType
createUpload_type :: Lens' CreateUpload UploadType
createUpload_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateUpload' {UploadType
type' :: UploadType
$sel:type':CreateUpload' :: CreateUpload -> UploadType
type'} -> UploadType
type') (\s :: CreateUpload
s@CreateUpload' {} UploadType
a -> CreateUpload
s {$sel:type':CreateUpload' :: UploadType
type' = UploadType
a} :: CreateUpload)
instance Core.AWSRequest CreateUpload where
type AWSResponse CreateUpload = CreateUploadResponse
request :: (Service -> Service) -> CreateUpload -> Request CreateUpload
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 CreateUpload
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateUpload)))
response =
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
( \Int
s ResponseHeaders
h Object
x ->
Maybe Upload -> Int -> CreateUploadResponse
CreateUploadResponse'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"upload")
forall (f :: * -> *) a b. Applicative f => 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 CreateUpload where
hashWithSalt :: Int -> CreateUpload -> Int
hashWithSalt Int
_salt CreateUpload' {Maybe Text
Text
UploadType
type' :: UploadType
name :: Text
projectArn :: Text
contentType :: Maybe Text
$sel:type':CreateUpload' :: CreateUpload -> UploadType
$sel:name:CreateUpload' :: CreateUpload -> Text
$sel:projectArn:CreateUpload' :: CreateUpload -> Text
$sel:contentType:CreateUpload' :: CreateUpload -> Maybe Text
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
contentType
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
projectArn
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` UploadType
type'
instance Prelude.NFData CreateUpload where
rnf :: CreateUpload -> ()
rnf CreateUpload' {Maybe Text
Text
UploadType
type' :: UploadType
name :: Text
projectArn :: Text
contentType :: Maybe Text
$sel:type':CreateUpload' :: CreateUpload -> UploadType
$sel:name:CreateUpload' :: CreateUpload -> Text
$sel:projectArn:CreateUpload' :: CreateUpload -> Text
$sel:contentType:CreateUpload' :: CreateUpload -> Maybe Text
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
contentType
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
projectArn
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf UploadType
type'
instance Data.ToHeaders CreateUpload where
toHeaders :: CreateUpload -> 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
"DeviceFarm_20150623.CreateUpload" ::
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 CreateUpload where
toJSON :: CreateUpload -> Value
toJSON CreateUpload' {Maybe Text
Text
UploadType
type' :: UploadType
name :: Text
projectArn :: Text
contentType :: Maybe Text
$sel:type':CreateUpload' :: CreateUpload -> UploadType
$sel:name:CreateUpload' :: CreateUpload -> Text
$sel:projectArn:CreateUpload' :: CreateUpload -> Text
$sel:contentType:CreateUpload' :: CreateUpload -> Maybe Text
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"contentType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
contentType,
forall a. a -> Maybe a
Prelude.Just (Key
"projectArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
projectArn),
forall a. a -> Maybe a
Prelude.Just (Key
"name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
forall a. a -> Maybe a
Prelude.Just (Key
"type" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= UploadType
type')
]
)
instance Data.ToPath CreateUpload where
toPath :: CreateUpload -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Data.ToQuery CreateUpload where
toQuery :: CreateUpload -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty
data CreateUploadResponse = CreateUploadResponse'
{
CreateUploadResponse -> Maybe Upload
upload :: Prelude.Maybe Upload,
CreateUploadResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateUploadResponse -> CreateUploadResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateUploadResponse -> CreateUploadResponse -> Bool
$c/= :: CreateUploadResponse -> CreateUploadResponse -> Bool
== :: CreateUploadResponse -> CreateUploadResponse -> Bool
$c== :: CreateUploadResponse -> CreateUploadResponse -> Bool
Prelude.Eq, Int -> CreateUploadResponse -> ShowS
[CreateUploadResponse] -> ShowS
CreateUploadResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateUploadResponse] -> ShowS
$cshowList :: [CreateUploadResponse] -> ShowS
show :: CreateUploadResponse -> String
$cshow :: CreateUploadResponse -> String
showsPrec :: Int -> CreateUploadResponse -> ShowS
$cshowsPrec :: Int -> CreateUploadResponse -> ShowS
Prelude.Show, forall x. Rep CreateUploadResponse x -> CreateUploadResponse
forall x. CreateUploadResponse -> Rep CreateUploadResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateUploadResponse x -> CreateUploadResponse
$cfrom :: forall x. CreateUploadResponse -> Rep CreateUploadResponse x
Prelude.Generic)
newCreateUploadResponse ::
Prelude.Int ->
CreateUploadResponse
newCreateUploadResponse :: Int -> CreateUploadResponse
newCreateUploadResponse Int
pHttpStatus_ =
CreateUploadResponse'
{ $sel:upload:CreateUploadResponse' :: Maybe Upload
upload = forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateUploadResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createUploadResponse_upload :: Lens.Lens' CreateUploadResponse (Prelude.Maybe Upload)
createUploadResponse_upload :: Lens' CreateUploadResponse (Maybe Upload)
createUploadResponse_upload = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateUploadResponse' {Maybe Upload
upload :: Maybe Upload
$sel:upload:CreateUploadResponse' :: CreateUploadResponse -> Maybe Upload
upload} -> Maybe Upload
upload) (\s :: CreateUploadResponse
s@CreateUploadResponse' {} Maybe Upload
a -> CreateUploadResponse
s {$sel:upload:CreateUploadResponse' :: Maybe Upload
upload = Maybe Upload
a} :: CreateUploadResponse)
createUploadResponse_httpStatus :: Lens.Lens' CreateUploadResponse Prelude.Int
createUploadResponse_httpStatus :: Lens' CreateUploadResponse Int
createUploadResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateUploadResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateUploadResponse' :: CreateUploadResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateUploadResponse
s@CreateUploadResponse' {} Int
a -> CreateUploadResponse
s {$sel:httpStatus:CreateUploadResponse' :: Int
httpStatus = Int
a} :: CreateUploadResponse)
instance Prelude.NFData CreateUploadResponse where
rnf :: CreateUploadResponse -> ()
rnf CreateUploadResponse' {Int
Maybe Upload
httpStatus :: Int
upload :: Maybe Upload
$sel:httpStatus:CreateUploadResponse' :: CreateUploadResponse -> Int
$sel:upload:CreateUploadResponse' :: CreateUploadResponse -> Maybe Upload
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Upload
upload
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus