{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Network.AWS.S3.PutObject
(
putObject
, PutObject
, poContentLength
, poExpires
, poGrantReadACP
, poSSECustomerAlgorithm
, poSSECustomerKey
, poRequestPayer
, poGrantWriteACP
, poWebsiteRedirectLocation
, poGrantRead
, poStorageClass
, poSSECustomerKeyMD5
, poSSEKMSKeyId
, poGrantFullControl
, poContentEncoding
, poTagging
, poContentMD5
, poMetadata
, poCacheControl
, poContentLanguage
, poACL
, poContentDisposition
, poServerSideEncryption
, poContentType
, poBucket
, poKey
, poBody
, putObjectResponse
, PutObjectResponse
, porsRequestCharged
, porsETag
, porsVersionId
, porsExpiration
, porsSSECustomerAlgorithm
, porsSSECustomerKeyMD5
, porsSSEKMSKeyId
, porsServerSideEncryption
, porsResponseStatus
) where
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
import Network.AWS.S3.Types
import Network.AWS.S3.Types.Product
data PutObject = PutObject'
{ _poContentLength :: !(Maybe Integer)
, _poExpires :: !(Maybe RFC822)
, _poGrantReadACP :: !(Maybe Text)
, _poSSECustomerAlgorithm :: !(Maybe Text)
, _poSSECustomerKey :: !(Maybe (Sensitive Text))
, _poRequestPayer :: !(Maybe RequestPayer)
, _poGrantWriteACP :: !(Maybe Text)
, _poWebsiteRedirectLocation :: !(Maybe Text)
, _poGrantRead :: !(Maybe Text)
, _poStorageClass :: !(Maybe StorageClass)
, _poSSECustomerKeyMD5 :: !(Maybe Text)
, _poSSEKMSKeyId :: !(Maybe (Sensitive Text))
, _poGrantFullControl :: !(Maybe Text)
, _poContentEncoding :: !(Maybe Text)
, _poTagging :: !(Maybe Text)
, _poContentMD5 :: !(Maybe Text)
, _poMetadata :: !(Map Text Text)
, _poCacheControl :: !(Maybe Text)
, _poContentLanguage :: !(Maybe Text)
, _poACL :: !(Maybe ObjectCannedACL)
, _poContentDisposition :: !(Maybe Text)
, _poServerSideEncryption :: !(Maybe ServerSideEncryption)
, _poContentType :: !(Maybe Text)
, _poBucket :: !BucketName
, _poKey :: !ObjectKey
, _poBody :: !RqBody
} deriving (Show, Generic)
putObject
:: BucketName
-> ObjectKey
-> RqBody
-> PutObject
putObject pBucket_ pKey_ pBody_ =
PutObject'
{ _poContentLength = Nothing
, _poExpires = Nothing
, _poGrantReadACP = Nothing
, _poSSECustomerAlgorithm = Nothing
, _poSSECustomerKey = Nothing
, _poRequestPayer = Nothing
, _poGrantWriteACP = Nothing
, _poWebsiteRedirectLocation = Nothing
, _poGrantRead = Nothing
, _poStorageClass = Nothing
, _poSSECustomerKeyMD5 = Nothing
, _poSSEKMSKeyId = Nothing
, _poGrantFullControl = Nothing
, _poContentEncoding = Nothing
, _poTagging = Nothing
, _poContentMD5 = Nothing
, _poMetadata = mempty
, _poCacheControl = Nothing
, _poContentLanguage = Nothing
, _poACL = Nothing
, _poContentDisposition = Nothing
, _poServerSideEncryption = Nothing
, _poContentType = Nothing
, _poBucket = pBucket_
, _poKey = pKey_
, _poBody = pBody_
}
poContentLength :: Lens' PutObject (Maybe Integer)
poContentLength = lens _poContentLength (\ s a -> s{_poContentLength = a})
poExpires :: Lens' PutObject (Maybe UTCTime)
poExpires = lens _poExpires (\ s a -> s{_poExpires = a}) . mapping _Time
poGrantReadACP :: Lens' PutObject (Maybe Text)
poGrantReadACP = lens _poGrantReadACP (\ s a -> s{_poGrantReadACP = a})
poSSECustomerAlgorithm :: Lens' PutObject (Maybe Text)
poSSECustomerAlgorithm = lens _poSSECustomerAlgorithm (\ s a -> s{_poSSECustomerAlgorithm = a})
poSSECustomerKey :: Lens' PutObject (Maybe Text)
poSSECustomerKey = lens _poSSECustomerKey (\ s a -> s{_poSSECustomerKey = a}) . mapping _Sensitive
poRequestPayer :: Lens' PutObject (Maybe RequestPayer)
poRequestPayer = lens _poRequestPayer (\ s a -> s{_poRequestPayer = a})
poGrantWriteACP :: Lens' PutObject (Maybe Text)
poGrantWriteACP = lens _poGrantWriteACP (\ s a -> s{_poGrantWriteACP = a})
poWebsiteRedirectLocation :: Lens' PutObject (Maybe Text)
poWebsiteRedirectLocation = lens _poWebsiteRedirectLocation (\ s a -> s{_poWebsiteRedirectLocation = a})
poGrantRead :: Lens' PutObject (Maybe Text)
poGrantRead = lens _poGrantRead (\ s a -> s{_poGrantRead = a})
poStorageClass :: Lens' PutObject (Maybe StorageClass)
poStorageClass = lens _poStorageClass (\ s a -> s{_poStorageClass = a})
poSSECustomerKeyMD5 :: Lens' PutObject (Maybe Text)
poSSECustomerKeyMD5 = lens _poSSECustomerKeyMD5 (\ s a -> s{_poSSECustomerKeyMD5 = a})
poSSEKMSKeyId :: Lens' PutObject (Maybe Text)
poSSEKMSKeyId = lens _poSSEKMSKeyId (\ s a -> s{_poSSEKMSKeyId = a}) . mapping _Sensitive
poGrantFullControl :: Lens' PutObject (Maybe Text)
poGrantFullControl = lens _poGrantFullControl (\ s a -> s{_poGrantFullControl = a})
poContentEncoding :: Lens' PutObject (Maybe Text)
poContentEncoding = lens _poContentEncoding (\ s a -> s{_poContentEncoding = a})
poTagging :: Lens' PutObject (Maybe Text)
poTagging = lens _poTagging (\ s a -> s{_poTagging = a})
poContentMD5 :: Lens' PutObject (Maybe Text)
poContentMD5 = lens _poContentMD5 (\ s a -> s{_poContentMD5 = a})
poMetadata :: Lens' PutObject (HashMap Text Text)
poMetadata = lens _poMetadata (\ s a -> s{_poMetadata = a}) . _Map
poCacheControl :: Lens' PutObject (Maybe Text)
poCacheControl = lens _poCacheControl (\ s a -> s{_poCacheControl = a})
poContentLanguage :: Lens' PutObject (Maybe Text)
poContentLanguage = lens _poContentLanguage (\ s a -> s{_poContentLanguage = a})
poACL :: Lens' PutObject (Maybe ObjectCannedACL)
poACL = lens _poACL (\ s a -> s{_poACL = a})
poContentDisposition :: Lens' PutObject (Maybe Text)
poContentDisposition = lens _poContentDisposition (\ s a -> s{_poContentDisposition = a})
poServerSideEncryption :: Lens' PutObject (Maybe ServerSideEncryption)
poServerSideEncryption = lens _poServerSideEncryption (\ s a -> s{_poServerSideEncryption = a})
poContentType :: Lens' PutObject (Maybe Text)
poContentType = lens _poContentType (\ s a -> s{_poContentType = a})
poBucket :: Lens' PutObject BucketName
poBucket = lens _poBucket (\ s a -> s{_poBucket = a})
poKey :: Lens' PutObject ObjectKey
poKey = lens _poKey (\ s a -> s{_poKey = a})
poBody :: Lens' PutObject RqBody
poBody = lens _poBody (\ s a -> s{_poBody = a})
instance AWSRequest PutObject where
type Rs PutObject = PutObjectResponse
request = expectHeader . putBody s3
response
= receiveEmpty
(\ s h x ->
PutObjectResponse' <$>
(h .#? "x-amz-request-charged") <*> (h .#? "ETag")
<*> (h .#? "x-amz-version-id")
<*> (h .#? "x-amz-expiration")
<*>
(h .#?
"x-amz-server-side-encryption-customer-algorithm")
<*>
(h .#?
"x-amz-server-side-encryption-customer-key-MD5")
<*>
(h .#? "x-amz-server-side-encryption-aws-kms-key-id")
<*> (h .#? "x-amz-server-side-encryption")
<*> (pure (fromEnum s)))
instance ToBody PutObject where
toBody = toBody . _poBody
instance ToHeaders PutObject where
toHeaders PutObject'{..}
= mconcat
["Content-Length" =# _poContentLength,
"Expires" =# _poExpires,
"x-amz-grant-read-acp" =# _poGrantReadACP,
"x-amz-server-side-encryption-customer-algorithm" =#
_poSSECustomerAlgorithm,
"x-amz-server-side-encryption-customer-key" =#
_poSSECustomerKey,
"x-amz-request-payer" =# _poRequestPayer,
"x-amz-grant-write-acp" =# _poGrantWriteACP,
"x-amz-website-redirect-location" =#
_poWebsiteRedirectLocation,
"x-amz-grant-read" =# _poGrantRead,
"x-amz-storage-class" =# _poStorageClass,
"x-amz-server-side-encryption-customer-key-MD5" =#
_poSSECustomerKeyMD5,
"x-amz-server-side-encryption-aws-kms-key-id" =#
_poSSEKMSKeyId,
"x-amz-grant-full-control" =# _poGrantFullControl,
"Content-Encoding" =# _poContentEncoding,
"x-amz-tagging" =# _poTagging,
"Content-MD5" =# _poContentMD5,
"x-amz-meta-" =# _poMetadata,
"Cache-Control" =# _poCacheControl,
"Content-Language" =# _poContentLanguage,
"x-amz-acl" =# _poACL,
"Content-Disposition" =# _poContentDisposition,
"x-amz-server-side-encryption" =#
_poServerSideEncryption,
"Content-Type" =# _poContentType]
instance ToPath PutObject where
toPath PutObject'{..}
= mconcat ["/", toBS _poBucket, "/", toBS _poKey]
instance ToQuery PutObject where
toQuery = const mempty
data PutObjectResponse = PutObjectResponse'
{ _porsRequestCharged :: !(Maybe RequestCharged)
, _porsETag :: !(Maybe ETag)
, _porsVersionId :: !(Maybe ObjectVersionId)
, _porsExpiration :: !(Maybe Text)
, _porsSSECustomerAlgorithm :: !(Maybe Text)
, _porsSSECustomerKeyMD5 :: !(Maybe Text)
, _porsSSEKMSKeyId :: !(Maybe (Sensitive Text))
, _porsServerSideEncryption :: !(Maybe ServerSideEncryption)
, _porsResponseStatus :: !Int
} deriving (Eq, Show, Data, Typeable, Generic)
putObjectResponse
:: Int
-> PutObjectResponse
putObjectResponse pResponseStatus_ =
PutObjectResponse'
{ _porsRequestCharged = Nothing
, _porsETag = Nothing
, _porsVersionId = Nothing
, _porsExpiration = Nothing
, _porsSSECustomerAlgorithm = Nothing
, _porsSSECustomerKeyMD5 = Nothing
, _porsSSEKMSKeyId = Nothing
, _porsServerSideEncryption = Nothing
, _porsResponseStatus = pResponseStatus_
}
porsRequestCharged :: Lens' PutObjectResponse (Maybe RequestCharged)
porsRequestCharged = lens _porsRequestCharged (\ s a -> s{_porsRequestCharged = a})
porsETag :: Lens' PutObjectResponse (Maybe ETag)
porsETag = lens _porsETag (\ s a -> s{_porsETag = a})
porsVersionId :: Lens' PutObjectResponse (Maybe ObjectVersionId)
porsVersionId = lens _porsVersionId (\ s a -> s{_porsVersionId = a})
porsExpiration :: Lens' PutObjectResponse (Maybe Text)
porsExpiration = lens _porsExpiration (\ s a -> s{_porsExpiration = a})
porsSSECustomerAlgorithm :: Lens' PutObjectResponse (Maybe Text)
porsSSECustomerAlgorithm = lens _porsSSECustomerAlgorithm (\ s a -> s{_porsSSECustomerAlgorithm = a})
porsSSECustomerKeyMD5 :: Lens' PutObjectResponse (Maybe Text)
porsSSECustomerKeyMD5 = lens _porsSSECustomerKeyMD5 (\ s a -> s{_porsSSECustomerKeyMD5 = a})
porsSSEKMSKeyId :: Lens' PutObjectResponse (Maybe Text)
porsSSEKMSKeyId = lens _porsSSEKMSKeyId (\ s a -> s{_porsSSEKMSKeyId = a}) . mapping _Sensitive
porsServerSideEncryption :: Lens' PutObjectResponse (Maybe ServerSideEncryption)
porsServerSideEncryption = lens _porsServerSideEncryption (\ s a -> s{_porsServerSideEncryption = a})
porsResponseStatus :: Lens' PutObjectResponse Int
porsResponseStatus = lens _porsResponseStatus (\ s a -> s{_porsResponseStatus = a})
instance NFData PutObjectResponse where