{-# 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.UploadPart
(
uploadPart
, UploadPart
, upContentLength
, upSSECustomerAlgorithm
, upSSECustomerKey
, upRequestPayer
, upSSECustomerKeyMD5
, upContentMD5
, upBucket
, upKey
, upPartNumber
, upUploadId
, upBody
, uploadPartResponse
, UploadPartResponse
, uprsRequestCharged
, uprsETag
, uprsSSECustomerAlgorithm
, uprsSSECustomerKeyMD5
, uprsSSEKMSKeyId
, uprsServerSideEncryption
, uprsResponseStatus
) 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 UploadPart = UploadPart'
{ _upContentLength :: !(Maybe Integer)
, _upSSECustomerAlgorithm :: !(Maybe Text)
, _upSSECustomerKey :: !(Maybe (Sensitive Text))
, _upRequestPayer :: !(Maybe RequestPayer)
, _upSSECustomerKeyMD5 :: !(Maybe Text)
, _upContentMD5 :: !(Maybe Text)
, _upBucket :: !BucketName
, _upKey :: !ObjectKey
, _upPartNumber :: !Int
, _upUploadId :: !Text
, _upBody :: !RqBody
} deriving (Show, Generic)
uploadPart
:: BucketName
-> ObjectKey
-> Int
-> Text
-> RqBody
-> UploadPart
uploadPart pBucket_ pKey_ pPartNumber_ pUploadId_ pBody_ =
UploadPart'
{ _upContentLength = Nothing
, _upSSECustomerAlgorithm = Nothing
, _upSSECustomerKey = Nothing
, _upRequestPayer = Nothing
, _upSSECustomerKeyMD5 = Nothing
, _upContentMD5 = Nothing
, _upBucket = pBucket_
, _upKey = pKey_
, _upPartNumber = pPartNumber_
, _upUploadId = pUploadId_
, _upBody = pBody_
}
upContentLength :: Lens' UploadPart (Maybe Integer)
upContentLength = lens _upContentLength (\ s a -> s{_upContentLength = a})
upSSECustomerAlgorithm :: Lens' UploadPart (Maybe Text)
upSSECustomerAlgorithm = lens _upSSECustomerAlgorithm (\ s a -> s{_upSSECustomerAlgorithm = a})
upSSECustomerKey :: Lens' UploadPart (Maybe Text)
upSSECustomerKey = lens _upSSECustomerKey (\ s a -> s{_upSSECustomerKey = a}) . mapping _Sensitive
upRequestPayer :: Lens' UploadPart (Maybe RequestPayer)
upRequestPayer = lens _upRequestPayer (\ s a -> s{_upRequestPayer = a})
upSSECustomerKeyMD5 :: Lens' UploadPart (Maybe Text)
upSSECustomerKeyMD5 = lens _upSSECustomerKeyMD5 (\ s a -> s{_upSSECustomerKeyMD5 = a})
upContentMD5 :: Lens' UploadPart (Maybe Text)
upContentMD5 = lens _upContentMD5 (\ s a -> s{_upContentMD5 = a})
upBucket :: Lens' UploadPart BucketName
upBucket = lens _upBucket (\ s a -> s{_upBucket = a})
upKey :: Lens' UploadPart ObjectKey
upKey = lens _upKey (\ s a -> s{_upKey = a})
upPartNumber :: Lens' UploadPart Int
upPartNumber = lens _upPartNumber (\ s a -> s{_upPartNumber = a})
upUploadId :: Lens' UploadPart Text
upUploadId = lens _upUploadId (\ s a -> s{_upUploadId = a})
upBody :: Lens' UploadPart RqBody
upBody = lens _upBody (\ s a -> s{_upBody = a})
instance AWSRequest UploadPart where
type Rs UploadPart = UploadPartResponse
request = putBody s3
response
= receiveEmpty
(\ s h x ->
UploadPartResponse' <$>
(h .#? "x-amz-request-charged") <*> (h .#? "ETag")
<*>
(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 UploadPart where
toBody = toBody . _upBody
instance ToHeaders UploadPart where
toHeaders UploadPart'{..}
= mconcat
["Content-Length" =# _upContentLength,
"x-amz-server-side-encryption-customer-algorithm" =#
_upSSECustomerAlgorithm,
"x-amz-server-side-encryption-customer-key" =#
_upSSECustomerKey,
"x-amz-request-payer" =# _upRequestPayer,
"x-amz-server-side-encryption-customer-key-MD5" =#
_upSSECustomerKeyMD5,
"Content-MD5" =# _upContentMD5]
instance ToPath UploadPart where
toPath UploadPart'{..}
= mconcat ["/", toBS _upBucket, "/", toBS _upKey]
instance ToQuery UploadPart where
toQuery UploadPart'{..}
= mconcat
["partNumber" =: _upPartNumber,
"uploadId" =: _upUploadId]
data UploadPartResponse = UploadPartResponse'
{ _uprsRequestCharged :: !(Maybe RequestCharged)
, _uprsETag :: !(Maybe ETag)
, _uprsSSECustomerAlgorithm :: !(Maybe Text)
, _uprsSSECustomerKeyMD5 :: !(Maybe Text)
, _uprsSSEKMSKeyId :: !(Maybe (Sensitive Text))
, _uprsServerSideEncryption :: !(Maybe ServerSideEncryption)
, _uprsResponseStatus :: !Int
} deriving (Eq, Show, Data, Typeable, Generic)
uploadPartResponse
:: Int
-> UploadPartResponse
uploadPartResponse pResponseStatus_ =
UploadPartResponse'
{ _uprsRequestCharged = Nothing
, _uprsETag = Nothing
, _uprsSSECustomerAlgorithm = Nothing
, _uprsSSECustomerKeyMD5 = Nothing
, _uprsSSEKMSKeyId = Nothing
, _uprsServerSideEncryption = Nothing
, _uprsResponseStatus = pResponseStatus_
}
uprsRequestCharged :: Lens' UploadPartResponse (Maybe RequestCharged)
uprsRequestCharged = lens _uprsRequestCharged (\ s a -> s{_uprsRequestCharged = a})
uprsETag :: Lens' UploadPartResponse (Maybe ETag)
uprsETag = lens _uprsETag (\ s a -> s{_uprsETag = a})
uprsSSECustomerAlgorithm :: Lens' UploadPartResponse (Maybe Text)
uprsSSECustomerAlgorithm = lens _uprsSSECustomerAlgorithm (\ s a -> s{_uprsSSECustomerAlgorithm = a})
uprsSSECustomerKeyMD5 :: Lens' UploadPartResponse (Maybe Text)
uprsSSECustomerKeyMD5 = lens _uprsSSECustomerKeyMD5 (\ s a -> s{_uprsSSECustomerKeyMD5 = a})
uprsSSEKMSKeyId :: Lens' UploadPartResponse (Maybe Text)
uprsSSEKMSKeyId = lens _uprsSSEKMSKeyId (\ s a -> s{_uprsSSEKMSKeyId = a}) . mapping _Sensitive
uprsServerSideEncryption :: Lens' UploadPartResponse (Maybe ServerSideEncryption)
uprsServerSideEncryption = lens _uprsServerSideEncryption (\ s a -> s{_uprsServerSideEncryption = a})
uprsResponseStatus :: Lens' UploadPartResponse Int
uprsResponseStatus = lens _uprsResponseStatus (\ s a -> s{_uprsResponseStatus = a})
instance NFData UploadPartResponse where