{-# 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.EC2.CreateImage
(
createImage
, CreateImage
, ciiNoReboot
, ciiDescription
, ciiBlockDeviceMappings
, ciiDryRun
, ciiInstanceId
, ciiName
, createImageResponse
, CreateImageResponse
, cirsImageId
, cirsResponseStatus
) where
import Network.AWS.EC2.Types
import Network.AWS.EC2.Types.Product
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data CreateImage = CreateImage'
{ _ciiNoReboot :: !(Maybe Bool)
, _ciiDescription :: !(Maybe Text)
, _ciiBlockDeviceMappings :: !(Maybe [BlockDeviceMapping])
, _ciiDryRun :: !(Maybe Bool)
, _ciiInstanceId :: !Text
, _ciiName :: !Text
} deriving (Eq,Read,Show,Data,Typeable,Generic)
createImage
:: Text
-> Text
-> CreateImage
createImage pInstanceId_ pName_ =
CreateImage'
{ _ciiNoReboot = Nothing
, _ciiDescription = Nothing
, _ciiBlockDeviceMappings = Nothing
, _ciiDryRun = Nothing
, _ciiInstanceId = pInstanceId_
, _ciiName = pName_
}
ciiNoReboot :: Lens' CreateImage (Maybe Bool)
ciiNoReboot = lens _ciiNoReboot (\ s a -> s{_ciiNoReboot = a});
ciiDescription :: Lens' CreateImage (Maybe Text)
ciiDescription = lens _ciiDescription (\ s a -> s{_ciiDescription = a});
ciiBlockDeviceMappings :: Lens' CreateImage [BlockDeviceMapping]
ciiBlockDeviceMappings = lens _ciiBlockDeviceMappings (\ s a -> s{_ciiBlockDeviceMappings = a}) . _Default . _Coerce;
ciiDryRun :: Lens' CreateImage (Maybe Bool)
ciiDryRun = lens _ciiDryRun (\ s a -> s{_ciiDryRun = a});
ciiInstanceId :: Lens' CreateImage Text
ciiInstanceId = lens _ciiInstanceId (\ s a -> s{_ciiInstanceId = a});
ciiName :: Lens' CreateImage Text
ciiName = lens _ciiName (\ s a -> s{_ciiName = a});
instance AWSRequest CreateImage where
type Rs CreateImage = CreateImageResponse
request = postQuery ec2
response
= receiveXML
(\ s h x ->
CreateImageResponse' <$>
(x .@? "imageId") <*> (pure (fromEnum s)))
instance Hashable CreateImage
instance NFData CreateImage
instance ToHeaders CreateImage where
toHeaders = const mempty
instance ToPath CreateImage where
toPath = const "/"
instance ToQuery CreateImage where
toQuery CreateImage'{..}
= mconcat
["Action" =: ("CreateImage" :: ByteString),
"Version" =: ("2016-04-01" :: ByteString),
"NoReboot" =: _ciiNoReboot,
"Description" =: _ciiDescription,
toQuery
(toQueryList "BlockDeviceMapping" <$>
_ciiBlockDeviceMappings),
"DryRun" =: _ciiDryRun,
"InstanceId" =: _ciiInstanceId, "Name" =: _ciiName]
data CreateImageResponse = CreateImageResponse'
{ _cirsImageId :: !(Maybe Text)
, _cirsResponseStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
createImageResponse
:: Int
-> CreateImageResponse
createImageResponse pResponseStatus_ =
CreateImageResponse'
{ _cirsImageId = Nothing
, _cirsResponseStatus = pResponseStatus_
}
cirsImageId :: Lens' CreateImageResponse (Maybe Text)
cirsImageId = lens _cirsImageId (\ s a -> s{_cirsImageId = a});
cirsResponseStatus :: Lens' CreateImageResponse Int
cirsResponseStatus = lens _cirsResponseStatus (\ s a -> s{_cirsResponseStatus = a});
instance NFData CreateImageResponse