module Network.AWS.S3.UploadPart
(
UploadPart
, uploadPart
, upBody
, upBucket
, upContentLength
, upContentMD5
, upKey
, upPartNumber
, upSSECustomerAlgorithm
, upSSECustomerKey
, upSSECustomerKeyMD5
, upUploadId
, UploadPartResponse
, uploadPartResponse
, uprETag
, uprSSECustomerAlgorithm
, uprSSECustomerKeyMD5
, uprSSEKMSKeyId
, uprServerSideEncryption
) where
import Network.AWS.Prelude
import Network.AWS.Request.S3
import Network.AWS.S3.Types
import qualified GHC.Exts
data UploadPart = UploadPart
{ _upBody :: RqBody
, _upBucket :: Text
, _upContentLength :: Maybe Int
, _upContentMD5 :: Maybe Text
, _upKey :: Text
, _upPartNumber :: Int
, _upSSECustomerAlgorithm :: Maybe Text
, _upSSECustomerKey :: Maybe (Sensitive Text)
, _upSSECustomerKeyMD5 :: Maybe Text
, _upUploadId :: Text
} deriving (Show)
uploadPart :: RqBody
-> Text
-> Text
-> Int
-> Text
-> UploadPart
uploadPart p1 p2 p3 p4 p5 = UploadPart
{ _upBody = p1
, _upBucket = p2
, _upKey = p3
, _upPartNumber = p4
, _upUploadId = p5
, _upContentLength = Nothing
, _upContentMD5 = Nothing
, _upSSECustomerAlgorithm = Nothing
, _upSSECustomerKey = Nothing
, _upSSECustomerKeyMD5 = Nothing
}
upBody :: Lens' UploadPart RqBody
upBody = lens _upBody (\s a -> s { _upBody = a })
upBucket :: Lens' UploadPart Text
upBucket = lens _upBucket (\s a -> s { _upBucket = a })
upContentLength :: Lens' UploadPart (Maybe Int)
upContentLength = lens _upContentLength (\s a -> s { _upContentLength = a })
upContentMD5 :: Lens' UploadPart (Maybe Text)
upContentMD5 = lens _upContentMD5 (\s a -> s { _upContentMD5 = a })
upKey :: Lens' UploadPart Text
upKey = lens _upKey (\s a -> s { _upKey = a })
upPartNumber :: Lens' UploadPart Int
upPartNumber = lens _upPartNumber (\s a -> s { _upPartNumber = 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
upSSECustomerKeyMD5 :: Lens' UploadPart (Maybe Text)
upSSECustomerKeyMD5 =
lens _upSSECustomerKeyMD5 (\s a -> s { _upSSECustomerKeyMD5 = a })
upUploadId :: Lens' UploadPart Text
upUploadId = lens _upUploadId (\s a -> s { _upUploadId = a })
data UploadPartResponse = UploadPartResponse
{ _uprETag :: Maybe Text
, _uprSSECustomerAlgorithm :: Maybe Text
, _uprSSECustomerKeyMD5 :: Maybe Text
, _uprSSEKMSKeyId :: Maybe (Sensitive Text)
, _uprServerSideEncryption :: Maybe ServerSideEncryption
} deriving (Eq, Read, Show)
uploadPartResponse :: UploadPartResponse
uploadPartResponse = UploadPartResponse
{ _uprServerSideEncryption = Nothing
, _uprETag = Nothing
, _uprSSECustomerAlgorithm = Nothing
, _uprSSECustomerKeyMD5 = Nothing
, _uprSSEKMSKeyId = Nothing
}
uprETag :: Lens' UploadPartResponse (Maybe Text)
uprETag = lens _uprETag (\s a -> s { _uprETag = a })
uprSSECustomerAlgorithm :: Lens' UploadPartResponse (Maybe Text)
uprSSECustomerAlgorithm =
lens _uprSSECustomerAlgorithm (\s a -> s { _uprSSECustomerAlgorithm = a })
uprSSECustomerKeyMD5 :: Lens' UploadPartResponse (Maybe Text)
uprSSECustomerKeyMD5 =
lens _uprSSECustomerKeyMD5 (\s a -> s { _uprSSECustomerKeyMD5 = a })
uprSSEKMSKeyId :: Lens' UploadPartResponse (Maybe Text)
uprSSEKMSKeyId = lens _uprSSEKMSKeyId (\s a -> s { _uprSSEKMSKeyId = a }) . mapping _Sensitive
uprServerSideEncryption :: Lens' UploadPartResponse (Maybe ServerSideEncryption)
uprServerSideEncryption =
lens _uprServerSideEncryption (\s a -> s { _uprServerSideEncryption = a })
instance ToPath UploadPart where
toPath UploadPart{..} = mconcat
[ "/"
, toText _upBucket
, "/"
, toText _upKey
]
instance ToQuery UploadPart where
toQuery UploadPart{..} = mconcat
[ "partNumber" =? _upPartNumber
, "uploadId" =? _upUploadId
]
instance ToHeaders UploadPart where
toHeaders UploadPart{..} = mconcat
[ "Content-Length" =: _upContentLength
, "Content-MD5" =: _upContentMD5
, "x-amz-server-side-encryption-customer-algorithm" =: _upSSECustomerAlgorithm
, "x-amz-server-side-encryption-customer-key" =: _upSSECustomerKey
, "x-amz-server-side-encryption-customer-key-MD5" =: _upSSECustomerKeyMD5
]
instance ToBody UploadPart where
toBody = toBody . _upBody
instance AWSRequest UploadPart where
type Sv UploadPart = S3
type Rs UploadPart = UploadPartResponse
request = stream PUT
response = headerResponse $ \h -> UploadPartResponse
<$> 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"