{-# 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 Amazonka.DeviceFarm.Types
import qualified Amazonka.Lens as Lens
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
(CreateUpload -> CreateUpload -> Bool)
-> (CreateUpload -> CreateUpload -> Bool) -> Eq CreateUpload
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]
(Int -> ReadS CreateUpload)
-> ReadS [CreateUpload]
-> ReadPrec CreateUpload
-> ReadPrec [CreateUpload]
-> Read 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
(Int -> CreateUpload -> ShowS)
-> (CreateUpload -> String)
-> ([CreateUpload] -> ShowS)
-> Show CreateUpload
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. CreateUpload -> Rep CreateUpload x)
-> (forall x. Rep CreateUpload x -> CreateUpload)
-> Generic CreateUpload
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' :: Maybe Text -> Text -> Text -> UploadType -> CreateUpload
CreateUpload'
{ $sel:contentType:CreateUpload' :: Maybe Text
contentType = Maybe Text
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 :: (Maybe Text -> f (Maybe Text)) -> CreateUpload -> f CreateUpload
createUpload_contentType = (CreateUpload -> Maybe Text)
-> (CreateUpload -> Maybe Text -> CreateUpload)
-> Lens CreateUpload CreateUpload (Maybe Text) (Maybe Text)
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 :: (Text -> f Text) -> CreateUpload -> f CreateUpload
createUpload_projectArn = (CreateUpload -> Text)
-> (CreateUpload -> Text -> CreateUpload)
-> Lens CreateUpload CreateUpload Text Text
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 :: (Text -> f Text) -> CreateUpload -> f CreateUpload
createUpload_name = (CreateUpload -> Text)
-> (CreateUpload -> Text -> CreateUpload)
-> Lens CreateUpload CreateUpload Text Text
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 :: (UploadType -> f UploadType) -> CreateUpload -> f CreateUpload
createUpload_type = (CreateUpload -> UploadType)
-> (CreateUpload -> UploadType -> CreateUpload)
-> Lens CreateUpload CreateUpload UploadType UploadType
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 :: CreateUpload -> Request CreateUpload
request = Service -> CreateUpload -> Request CreateUpload
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateUpload
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateUpload)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateUpload))
-> Logger
-> Service
-> Proxy CreateUpload
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateUpload)))
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 Upload -> Int -> CreateUploadResponse
CreateUploadResponse'
(Maybe Upload -> Int -> CreateUploadResponse)
-> Either String (Maybe Upload)
-> Either String (Int -> CreateUploadResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Upload)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"upload")
Either String (Int -> CreateUploadResponse)
-> Either String Int -> Either String CreateUploadResponse
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 CreateUpload
instance Prelude.NFData CreateUpload
instance Core.ToHeaders CreateUpload where
toHeaders :: CreateUpload -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateUpload -> 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
"DeviceFarm_20150623.CreateUpload" ::
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 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
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"contentType" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
contentType,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"projectArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
projectArn),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"type" Text -> UploadType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= UploadType
type')
]
)
instance Core.ToPath CreateUpload where
toPath :: CreateUpload -> ByteString
toPath = ByteString -> CreateUpload -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery CreateUpload where
toQuery :: CreateUpload -> QueryString
toQuery = QueryString -> CreateUpload -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(CreateUploadResponse -> CreateUploadResponse -> Bool)
-> (CreateUploadResponse -> CreateUploadResponse -> Bool)
-> Eq CreateUploadResponse
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
(Int -> CreateUploadResponse -> ShowS)
-> (CreateUploadResponse -> String)
-> ([CreateUploadResponse] -> ShowS)
-> Show CreateUploadResponse
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. CreateUploadResponse -> Rep CreateUploadResponse x)
-> (forall x. Rep CreateUploadResponse x -> CreateUploadResponse)
-> Generic CreateUploadResponse
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' :: Maybe Upload -> Int -> CreateUploadResponse
CreateUploadResponse'
{ $sel:upload:CreateUploadResponse' :: Maybe Upload
upload = Maybe Upload
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateUploadResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createUploadResponse_upload :: Lens.Lens' CreateUploadResponse (Prelude.Maybe Upload)
createUploadResponse_upload :: (Maybe Upload -> f (Maybe Upload))
-> CreateUploadResponse -> f CreateUploadResponse
createUploadResponse_upload = (CreateUploadResponse -> Maybe Upload)
-> (CreateUploadResponse -> Maybe Upload -> CreateUploadResponse)
-> Lens
CreateUploadResponse
CreateUploadResponse
(Maybe Upload)
(Maybe 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 :: (Int -> f Int) -> CreateUploadResponse -> f CreateUploadResponse
createUploadResponse_httpStatus = (CreateUploadResponse -> Int)
-> (CreateUploadResponse -> Int -> CreateUploadResponse)
-> Lens CreateUploadResponse CreateUploadResponse Int Int
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