{-# 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.ECR.UploadLayerPart
(
uploadLayerPart
, UploadLayerPart
, ulpRegistryId
, ulpRepositoryName
, ulpUploadId
, ulpPartFirstByte
, ulpPartLastByte
, ulpLayerPartBlob
, uploadLayerPartResponse
, UploadLayerPartResponse
, ulprsRegistryId
, ulprsLastByteReceived
, ulprsRepositoryName
, ulprsUploadId
, ulprsResponseStatus
) where
import Network.AWS.ECR.Types
import Network.AWS.ECR.Types.Product
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data UploadLayerPart = UploadLayerPart'
{ _ulpRegistryId :: !(Maybe Text)
, _ulpRepositoryName :: !Text
, _ulpUploadId :: !Text
, _ulpPartFirstByte :: !Nat
, _ulpPartLastByte :: !Nat
, _ulpLayerPartBlob :: !Base64
} deriving (Eq,Read,Show,Data,Typeable,Generic)
uploadLayerPart
:: Text
-> Text
-> Natural
-> Natural
-> ByteString
-> UploadLayerPart
uploadLayerPart pRepositoryName_ pUploadId_ pPartFirstByte_ pPartLastByte_ pLayerPartBlob_ =
UploadLayerPart'
{ _ulpRegistryId = Nothing
, _ulpRepositoryName = pRepositoryName_
, _ulpUploadId = pUploadId_
, _ulpPartFirstByte = _Nat # pPartFirstByte_
, _ulpPartLastByte = _Nat # pPartLastByte_
, _ulpLayerPartBlob = _Base64 # pLayerPartBlob_
}
ulpRegistryId :: Lens' UploadLayerPart (Maybe Text)
ulpRegistryId = lens _ulpRegistryId (\ s a -> s{_ulpRegistryId = a});
ulpRepositoryName :: Lens' UploadLayerPart Text
ulpRepositoryName = lens _ulpRepositoryName (\ s a -> s{_ulpRepositoryName = a});
ulpUploadId :: Lens' UploadLayerPart Text
ulpUploadId = lens _ulpUploadId (\ s a -> s{_ulpUploadId = a});
ulpPartFirstByte :: Lens' UploadLayerPart Natural
ulpPartFirstByte = lens _ulpPartFirstByte (\ s a -> s{_ulpPartFirstByte = a}) . _Nat;
ulpPartLastByte :: Lens' UploadLayerPart Natural
ulpPartLastByte = lens _ulpPartLastByte (\ s a -> s{_ulpPartLastByte = a}) . _Nat;
ulpLayerPartBlob :: Lens' UploadLayerPart ByteString
ulpLayerPartBlob = lens _ulpLayerPartBlob (\ s a -> s{_ulpLayerPartBlob = a}) . _Base64;
instance AWSRequest UploadLayerPart where
type Rs UploadLayerPart = UploadLayerPartResponse
request = postJSON ecr
response
= receiveJSON
(\ s h x ->
UploadLayerPartResponse' <$>
(x .?> "registryId") <*> (x .?> "lastByteReceived")
<*> (x .?> "repositoryName")
<*> (x .?> "uploadId")
<*> (pure (fromEnum s)))
instance Hashable UploadLayerPart
instance NFData UploadLayerPart
instance ToHeaders UploadLayerPart where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("AmazonEC2ContainerRegistry_V20150921.UploadLayerPart"
:: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON UploadLayerPart where
toJSON UploadLayerPart'{..}
= object
(catMaybes
[("registryId" .=) <$> _ulpRegistryId,
Just ("repositoryName" .= _ulpRepositoryName),
Just ("uploadId" .= _ulpUploadId),
Just ("partFirstByte" .= _ulpPartFirstByte),
Just ("partLastByte" .= _ulpPartLastByte),
Just ("layerPartBlob" .= _ulpLayerPartBlob)])
instance ToPath UploadLayerPart where
toPath = const "/"
instance ToQuery UploadLayerPart where
toQuery = const mempty
data UploadLayerPartResponse = UploadLayerPartResponse'
{ _ulprsRegistryId :: !(Maybe Text)
, _ulprsLastByteReceived :: !(Maybe Nat)
, _ulprsRepositoryName :: !(Maybe Text)
, _ulprsUploadId :: !(Maybe Text)
, _ulprsResponseStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
uploadLayerPartResponse
:: Int
-> UploadLayerPartResponse
uploadLayerPartResponse pResponseStatus_ =
UploadLayerPartResponse'
{ _ulprsRegistryId = Nothing
, _ulprsLastByteReceived = Nothing
, _ulprsRepositoryName = Nothing
, _ulprsUploadId = Nothing
, _ulprsResponseStatus = pResponseStatus_
}
ulprsRegistryId :: Lens' UploadLayerPartResponse (Maybe Text)
ulprsRegistryId = lens _ulprsRegistryId (\ s a -> s{_ulprsRegistryId = a});
ulprsLastByteReceived :: Lens' UploadLayerPartResponse (Maybe Natural)
ulprsLastByteReceived = lens _ulprsLastByteReceived (\ s a -> s{_ulprsLastByteReceived = a}) . mapping _Nat;
ulprsRepositoryName :: Lens' UploadLayerPartResponse (Maybe Text)
ulprsRepositoryName = lens _ulprsRepositoryName (\ s a -> s{_ulprsRepositoryName = a});
ulprsUploadId :: Lens' UploadLayerPartResponse (Maybe Text)
ulprsUploadId = lens _ulprsUploadId (\ s a -> s{_ulprsUploadId = a});
ulprsResponseStatus :: Lens' UploadLayerPartResponse Int
ulprsResponseStatus = lens _ulprsResponseStatus (\ s a -> s{_ulprsResponseStatus = a});
instance NFData UploadLayerPartResponse