{-# 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.MediaStoreData.PutObject
(
PutObject (..),
newPutObject,
putObject_storageClass,
putObject_uploadAvailability,
putObject_cacheControl,
putObject_contentType,
putObject_path,
putObject_body,
PutObjectResponse (..),
newPutObjectResponse,
putObjectResponse_eTag,
putObjectResponse_storageClass,
putObjectResponse_contentSHA256,
putObjectResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MediaStoreData.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data PutObject = PutObject'
{
PutObject -> Maybe StorageClass
storageClass :: Prelude.Maybe StorageClass,
PutObject -> Maybe UploadAvailability
uploadAvailability :: Prelude.Maybe UploadAvailability,
PutObject -> Maybe Text
cacheControl :: Prelude.Maybe Prelude.Text,
PutObject -> Maybe Text
contentType :: Prelude.Maybe Prelude.Text,
PutObject -> Text
path :: Prelude.Text,
PutObject -> HashedBody
body :: Core.HashedBody
}
deriving (Int -> PutObject -> ShowS
[PutObject] -> ShowS
PutObject -> String
(Int -> PutObject -> ShowS)
-> (PutObject -> String)
-> ([PutObject] -> ShowS)
-> Show PutObject
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutObject] -> ShowS
$cshowList :: [PutObject] -> ShowS
show :: PutObject -> String
$cshow :: PutObject -> String
showsPrec :: Int -> PutObject -> ShowS
$cshowsPrec :: Int -> PutObject -> ShowS
Prelude.Show, (forall x. PutObject -> Rep PutObject x)
-> (forall x. Rep PutObject x -> PutObject) -> Generic PutObject
forall x. Rep PutObject x -> PutObject
forall x. PutObject -> Rep PutObject x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutObject x -> PutObject
$cfrom :: forall x. PutObject -> Rep PutObject x
Prelude.Generic)
newPutObject ::
Prelude.Text ->
Core.HashedBody ->
PutObject
newPutObject :: Text -> HashedBody -> PutObject
newPutObject Text
pPath_ HashedBody
pBody_ =
PutObject' :: Maybe StorageClass
-> Maybe UploadAvailability
-> Maybe Text
-> Maybe Text
-> Text
-> HashedBody
-> PutObject
PutObject'
{ $sel:storageClass:PutObject' :: Maybe StorageClass
storageClass = Maybe StorageClass
forall a. Maybe a
Prelude.Nothing,
$sel:uploadAvailability:PutObject' :: Maybe UploadAvailability
uploadAvailability = Maybe UploadAvailability
forall a. Maybe a
Prelude.Nothing,
$sel:cacheControl:PutObject' :: Maybe Text
cacheControl = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:contentType:PutObject' :: Maybe Text
contentType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:path:PutObject' :: Text
path = Text
pPath_,
$sel:body:PutObject' :: HashedBody
body = HashedBody
pBody_
}
putObject_storageClass :: Lens.Lens' PutObject (Prelude.Maybe StorageClass)
putObject_storageClass :: (Maybe StorageClass -> f (Maybe StorageClass))
-> PutObject -> f PutObject
putObject_storageClass = (PutObject -> Maybe StorageClass)
-> (PutObject -> Maybe StorageClass -> PutObject)
-> Lens
PutObject PutObject (Maybe StorageClass) (Maybe StorageClass)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutObject' {Maybe StorageClass
storageClass :: Maybe StorageClass
$sel:storageClass:PutObject' :: PutObject -> Maybe StorageClass
storageClass} -> Maybe StorageClass
storageClass) (\s :: PutObject
s@PutObject' {} Maybe StorageClass
a -> PutObject
s {$sel:storageClass:PutObject' :: Maybe StorageClass
storageClass = Maybe StorageClass
a} :: PutObject)
putObject_uploadAvailability :: Lens.Lens' PutObject (Prelude.Maybe UploadAvailability)
putObject_uploadAvailability :: (Maybe UploadAvailability -> f (Maybe UploadAvailability))
-> PutObject -> f PutObject
putObject_uploadAvailability = (PutObject -> Maybe UploadAvailability)
-> (PutObject -> Maybe UploadAvailability -> PutObject)
-> Lens
PutObject
PutObject
(Maybe UploadAvailability)
(Maybe UploadAvailability)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutObject' {Maybe UploadAvailability
uploadAvailability :: Maybe UploadAvailability
$sel:uploadAvailability:PutObject' :: PutObject -> Maybe UploadAvailability
uploadAvailability} -> Maybe UploadAvailability
uploadAvailability) (\s :: PutObject
s@PutObject' {} Maybe UploadAvailability
a -> PutObject
s {$sel:uploadAvailability:PutObject' :: Maybe UploadAvailability
uploadAvailability = Maybe UploadAvailability
a} :: PutObject)
putObject_cacheControl :: Lens.Lens' PutObject (Prelude.Maybe Prelude.Text)
putObject_cacheControl :: (Maybe Text -> f (Maybe Text)) -> PutObject -> f PutObject
putObject_cacheControl = (PutObject -> Maybe Text)
-> (PutObject -> Maybe Text -> PutObject)
-> Lens PutObject PutObject (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutObject' {Maybe Text
cacheControl :: Maybe Text
$sel:cacheControl:PutObject' :: PutObject -> Maybe Text
cacheControl} -> Maybe Text
cacheControl) (\s :: PutObject
s@PutObject' {} Maybe Text
a -> PutObject
s {$sel:cacheControl:PutObject' :: Maybe Text
cacheControl = Maybe Text
a} :: PutObject)
putObject_contentType :: Lens.Lens' PutObject (Prelude.Maybe Prelude.Text)
putObject_contentType :: (Maybe Text -> f (Maybe Text)) -> PutObject -> f PutObject
putObject_contentType = (PutObject -> Maybe Text)
-> (PutObject -> Maybe Text -> PutObject)
-> Lens PutObject PutObject (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutObject' {Maybe Text
contentType :: Maybe Text
$sel:contentType:PutObject' :: PutObject -> Maybe Text
contentType} -> Maybe Text
contentType) (\s :: PutObject
s@PutObject' {} Maybe Text
a -> PutObject
s {$sel:contentType:PutObject' :: Maybe Text
contentType = Maybe Text
a} :: PutObject)
putObject_path :: Lens.Lens' PutObject Prelude.Text
putObject_path :: (Text -> f Text) -> PutObject -> f PutObject
putObject_path = (PutObject -> Text)
-> (PutObject -> Text -> PutObject)
-> Lens PutObject PutObject Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutObject' {Text
path :: Text
$sel:path:PutObject' :: PutObject -> Text
path} -> Text
path) (\s :: PutObject
s@PutObject' {} Text
a -> PutObject
s {$sel:path:PutObject' :: Text
path = Text
a} :: PutObject)
putObject_body :: Lens.Lens' PutObject Core.HashedBody
putObject_body :: (HashedBody -> f HashedBody) -> PutObject -> f PutObject
putObject_body = (PutObject -> HashedBody)
-> (PutObject -> HashedBody -> PutObject)
-> Lens PutObject PutObject HashedBody HashedBody
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutObject' {HashedBody
body :: HashedBody
$sel:body:PutObject' :: PutObject -> HashedBody
body} -> HashedBody
body) (\s :: PutObject
s@PutObject' {} HashedBody
a -> PutObject
s {$sel:body:PutObject' :: HashedBody
body = HashedBody
a} :: PutObject)
instance Core.AWSRequest PutObject where
type AWSResponse PutObject = PutObjectResponse
request :: PutObject -> Request PutObject
request = Service -> PutObject -> Request PutObject
forall a. (ToRequest a, ToBody a) => Service -> a -> Request a
Request.putBody Service
defaultService
response :: Logger
-> Service
-> Proxy PutObject
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutObject)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse PutObject))
-> Logger
-> Service
-> Proxy PutObject
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutObject)))
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
-> Maybe StorageClass -> Maybe Text -> Int -> PutObjectResponse
PutObjectResponse'
(Maybe Text
-> Maybe StorageClass -> Maybe Text -> Int -> PutObjectResponse)
-> Either String (Maybe Text)
-> Either
String
(Maybe StorageClass -> Maybe Text -> Int -> PutObjectResponse)
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
"ETag")
Either
String
(Maybe StorageClass -> Maybe Text -> Int -> PutObjectResponse)
-> Either String (Maybe StorageClass)
-> Either String (Maybe Text -> Int -> PutObjectResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe StorageClass)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"StorageClass")
Either String (Maybe Text -> Int -> PutObjectResponse)
-> Either String (Maybe Text)
-> Either String (Int -> PutObjectResponse)
forall (f :: * -> *) a b. Applicative f => 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
"ContentSHA256")
Either String (Int -> PutObjectResponse)
-> Either String Int -> Either String PutObjectResponse
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 Core.ToBody PutObject where
toBody :: PutObject -> RequestBody
toBody PutObject' {Maybe Text
Maybe StorageClass
Maybe UploadAvailability
Text
HashedBody
body :: HashedBody
path :: Text
contentType :: Maybe Text
cacheControl :: Maybe Text
uploadAvailability :: Maybe UploadAvailability
storageClass :: Maybe StorageClass
$sel:body:PutObject' :: PutObject -> HashedBody
$sel:path:PutObject' :: PutObject -> Text
$sel:contentType:PutObject' :: PutObject -> Maybe Text
$sel:cacheControl:PutObject' :: PutObject -> Maybe Text
$sel:uploadAvailability:PutObject' :: PutObject -> Maybe UploadAvailability
$sel:storageClass:PutObject' :: PutObject -> Maybe StorageClass
..} = HashedBody -> RequestBody
forall a. ToBody a => a -> RequestBody
Core.toBody HashedBody
body
instance Core.ToHeaders PutObject where
toHeaders :: PutObject -> ResponseHeaders
toHeaders PutObject' {Maybe Text
Maybe StorageClass
Maybe UploadAvailability
Text
HashedBody
body :: HashedBody
path :: Text
contentType :: Maybe Text
cacheControl :: Maybe Text
uploadAvailability :: Maybe UploadAvailability
storageClass :: Maybe StorageClass
$sel:body:PutObject' :: PutObject -> HashedBody
$sel:path:PutObject' :: PutObject -> Text
$sel:contentType:PutObject' :: PutObject -> Maybe Text
$sel:cacheControl:PutObject' :: PutObject -> Maybe Text
$sel:uploadAvailability:PutObject' :: PutObject -> Maybe UploadAvailability
$sel:storageClass:PutObject' :: PutObject -> Maybe StorageClass
..} =
[ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"x-amz-storage-class" HeaderName -> Maybe StorageClass -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Maybe StorageClass
storageClass,
HeaderName
"x-amz-upload-availability"
HeaderName -> Maybe UploadAvailability -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Maybe UploadAvailability
uploadAvailability,
HeaderName
"Cache-Control" HeaderName -> Maybe Text -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Maybe Text
cacheControl,
HeaderName
"Content-Type" HeaderName -> Maybe Text -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Maybe Text
contentType
]
instance Core.ToPath PutObject where
toPath :: PutObject -> ByteString
toPath PutObject' {Maybe Text
Maybe StorageClass
Maybe UploadAvailability
Text
HashedBody
body :: HashedBody
path :: Text
contentType :: Maybe Text
cacheControl :: Maybe Text
uploadAvailability :: Maybe UploadAvailability
storageClass :: Maybe StorageClass
$sel:body:PutObject' :: PutObject -> HashedBody
$sel:path:PutObject' :: PutObject -> Text
$sel:contentType:PutObject' :: PutObject -> Maybe Text
$sel:cacheControl:PutObject' :: PutObject -> Maybe Text
$sel:uploadAvailability:PutObject' :: PutObject -> Maybe UploadAvailability
$sel:storageClass:PutObject' :: PutObject -> Maybe StorageClass
..} =
[ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
path]
instance Core.ToQuery PutObject where
toQuery :: PutObject -> QueryString
toQuery = QueryString -> PutObject -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data PutObjectResponse = PutObjectResponse'
{
PutObjectResponse -> Maybe Text
eTag :: Prelude.Maybe Prelude.Text,
PutObjectResponse -> Maybe StorageClass
storageClass :: Prelude.Maybe StorageClass,
PutObjectResponse -> Maybe Text
contentSHA256 :: Prelude.Maybe Prelude.Text,
PutObjectResponse -> Int
httpStatus :: Prelude.Int
}
deriving (PutObjectResponse -> PutObjectResponse -> Bool
(PutObjectResponse -> PutObjectResponse -> Bool)
-> (PutObjectResponse -> PutObjectResponse -> Bool)
-> Eq PutObjectResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutObjectResponse -> PutObjectResponse -> Bool
$c/= :: PutObjectResponse -> PutObjectResponse -> Bool
== :: PutObjectResponse -> PutObjectResponse -> Bool
$c== :: PutObjectResponse -> PutObjectResponse -> Bool
Prelude.Eq, ReadPrec [PutObjectResponse]
ReadPrec PutObjectResponse
Int -> ReadS PutObjectResponse
ReadS [PutObjectResponse]
(Int -> ReadS PutObjectResponse)
-> ReadS [PutObjectResponse]
-> ReadPrec PutObjectResponse
-> ReadPrec [PutObjectResponse]
-> Read PutObjectResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutObjectResponse]
$creadListPrec :: ReadPrec [PutObjectResponse]
readPrec :: ReadPrec PutObjectResponse
$creadPrec :: ReadPrec PutObjectResponse
readList :: ReadS [PutObjectResponse]
$creadList :: ReadS [PutObjectResponse]
readsPrec :: Int -> ReadS PutObjectResponse
$creadsPrec :: Int -> ReadS PutObjectResponse
Prelude.Read, Int -> PutObjectResponse -> ShowS
[PutObjectResponse] -> ShowS
PutObjectResponse -> String
(Int -> PutObjectResponse -> ShowS)
-> (PutObjectResponse -> String)
-> ([PutObjectResponse] -> ShowS)
-> Show PutObjectResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutObjectResponse] -> ShowS
$cshowList :: [PutObjectResponse] -> ShowS
show :: PutObjectResponse -> String
$cshow :: PutObjectResponse -> String
showsPrec :: Int -> PutObjectResponse -> ShowS
$cshowsPrec :: Int -> PutObjectResponse -> ShowS
Prelude.Show, (forall x. PutObjectResponse -> Rep PutObjectResponse x)
-> (forall x. Rep PutObjectResponse x -> PutObjectResponse)
-> Generic PutObjectResponse
forall x. Rep PutObjectResponse x -> PutObjectResponse
forall x. PutObjectResponse -> Rep PutObjectResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutObjectResponse x -> PutObjectResponse
$cfrom :: forall x. PutObjectResponse -> Rep PutObjectResponse x
Prelude.Generic)
newPutObjectResponse ::
Prelude.Int ->
PutObjectResponse
newPutObjectResponse :: Int -> PutObjectResponse
newPutObjectResponse Int
pHttpStatus_ =
PutObjectResponse' :: Maybe Text
-> Maybe StorageClass -> Maybe Text -> Int -> PutObjectResponse
PutObjectResponse'
{ $sel:eTag:PutObjectResponse' :: Maybe Text
eTag = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:storageClass:PutObjectResponse' :: Maybe StorageClass
storageClass = Maybe StorageClass
forall a. Maybe a
Prelude.Nothing,
$sel:contentSHA256:PutObjectResponse' :: Maybe Text
contentSHA256 = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:PutObjectResponse' :: Int
httpStatus = Int
pHttpStatus_
}
putObjectResponse_eTag :: Lens.Lens' PutObjectResponse (Prelude.Maybe Prelude.Text)
putObjectResponse_eTag :: (Maybe Text -> f (Maybe Text))
-> PutObjectResponse -> f PutObjectResponse
putObjectResponse_eTag = (PutObjectResponse -> Maybe Text)
-> (PutObjectResponse -> Maybe Text -> PutObjectResponse)
-> Lens
PutObjectResponse PutObjectResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutObjectResponse' {Maybe Text
eTag :: Maybe Text
$sel:eTag:PutObjectResponse' :: PutObjectResponse -> Maybe Text
eTag} -> Maybe Text
eTag) (\s :: PutObjectResponse
s@PutObjectResponse' {} Maybe Text
a -> PutObjectResponse
s {$sel:eTag:PutObjectResponse' :: Maybe Text
eTag = Maybe Text
a} :: PutObjectResponse)
putObjectResponse_storageClass :: Lens.Lens' PutObjectResponse (Prelude.Maybe StorageClass)
putObjectResponse_storageClass :: (Maybe StorageClass -> f (Maybe StorageClass))
-> PutObjectResponse -> f PutObjectResponse
putObjectResponse_storageClass = (PutObjectResponse -> Maybe StorageClass)
-> (PutObjectResponse -> Maybe StorageClass -> PutObjectResponse)
-> Lens
PutObjectResponse
PutObjectResponse
(Maybe StorageClass)
(Maybe StorageClass)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutObjectResponse' {Maybe StorageClass
storageClass :: Maybe StorageClass
$sel:storageClass:PutObjectResponse' :: PutObjectResponse -> Maybe StorageClass
storageClass} -> Maybe StorageClass
storageClass) (\s :: PutObjectResponse
s@PutObjectResponse' {} Maybe StorageClass
a -> PutObjectResponse
s {$sel:storageClass:PutObjectResponse' :: Maybe StorageClass
storageClass = Maybe StorageClass
a} :: PutObjectResponse)
putObjectResponse_contentSHA256 :: Lens.Lens' PutObjectResponse (Prelude.Maybe Prelude.Text)
putObjectResponse_contentSHA256 :: (Maybe Text -> f (Maybe Text))
-> PutObjectResponse -> f PutObjectResponse
putObjectResponse_contentSHA256 = (PutObjectResponse -> Maybe Text)
-> (PutObjectResponse -> Maybe Text -> PutObjectResponse)
-> Lens
PutObjectResponse PutObjectResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutObjectResponse' {Maybe Text
contentSHA256 :: Maybe Text
$sel:contentSHA256:PutObjectResponse' :: PutObjectResponse -> Maybe Text
contentSHA256} -> Maybe Text
contentSHA256) (\s :: PutObjectResponse
s@PutObjectResponse' {} Maybe Text
a -> PutObjectResponse
s {$sel:contentSHA256:PutObjectResponse' :: Maybe Text
contentSHA256 = Maybe Text
a} :: PutObjectResponse)
putObjectResponse_httpStatus :: Lens.Lens' PutObjectResponse Prelude.Int
putObjectResponse_httpStatus :: (Int -> f Int) -> PutObjectResponse -> f PutObjectResponse
putObjectResponse_httpStatus = (PutObjectResponse -> Int)
-> (PutObjectResponse -> Int -> PutObjectResponse)
-> Lens PutObjectResponse PutObjectResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutObjectResponse' {Int
httpStatus :: Int
$sel:httpStatus:PutObjectResponse' :: PutObjectResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: PutObjectResponse
s@PutObjectResponse' {} Int
a -> PutObjectResponse
s {$sel:httpStatus:PutObjectResponse' :: Int
httpStatus = Int
a} :: PutObjectResponse)
instance Prelude.NFData PutObjectResponse