{-# 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.Lightsail.CreateDiskFromSnapshot
(
createDiskFromSnapshot
, CreateDiskFromSnapshot
, cdfsDiskName
, cdfsDiskSnapshotName
, cdfsAvailabilityZone
, cdfsSizeInGb
, createDiskFromSnapshotResponse
, CreateDiskFromSnapshotResponse
, cdfsrsOperations
, cdfsrsResponseStatus
) where
import Network.AWS.Lens
import Network.AWS.Lightsail.Types
import Network.AWS.Lightsail.Types.Product
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data CreateDiskFromSnapshot = CreateDiskFromSnapshot'
{ _cdfsDiskName :: !Text
, _cdfsDiskSnapshotName :: !Text
, _cdfsAvailabilityZone :: !Text
, _cdfsSizeInGb :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createDiskFromSnapshot
:: Text
-> Text
-> Text
-> Int
-> CreateDiskFromSnapshot
createDiskFromSnapshot pDiskName_ pDiskSnapshotName_ pAvailabilityZone_ pSizeInGb_ =
CreateDiskFromSnapshot'
{ _cdfsDiskName = pDiskName_
, _cdfsDiskSnapshotName = pDiskSnapshotName_
, _cdfsAvailabilityZone = pAvailabilityZone_
, _cdfsSizeInGb = pSizeInGb_
}
cdfsDiskName :: Lens' CreateDiskFromSnapshot Text
cdfsDiskName = lens _cdfsDiskName (\ s a -> s{_cdfsDiskName = a})
cdfsDiskSnapshotName :: Lens' CreateDiskFromSnapshot Text
cdfsDiskSnapshotName = lens _cdfsDiskSnapshotName (\ s a -> s{_cdfsDiskSnapshotName = a})
cdfsAvailabilityZone :: Lens' CreateDiskFromSnapshot Text
cdfsAvailabilityZone = lens _cdfsAvailabilityZone (\ s a -> s{_cdfsAvailabilityZone = a})
cdfsSizeInGb :: Lens' CreateDiskFromSnapshot Int
cdfsSizeInGb = lens _cdfsSizeInGb (\ s a -> s{_cdfsSizeInGb = a})
instance AWSRequest CreateDiskFromSnapshot where
type Rs CreateDiskFromSnapshot =
CreateDiskFromSnapshotResponse
request = postJSON lightsail
response
= receiveJSON
(\ s h x ->
CreateDiskFromSnapshotResponse' <$>
(x .?> "operations" .!@ mempty) <*>
(pure (fromEnum s)))
instance Hashable CreateDiskFromSnapshot where
instance NFData CreateDiskFromSnapshot where
instance ToHeaders CreateDiskFromSnapshot where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("Lightsail_20161128.CreateDiskFromSnapshot" ::
ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON CreateDiskFromSnapshot where
toJSON CreateDiskFromSnapshot'{..}
= object
(catMaybes
[Just ("diskName" .= _cdfsDiskName),
Just ("diskSnapshotName" .= _cdfsDiskSnapshotName),
Just ("availabilityZone" .= _cdfsAvailabilityZone),
Just ("sizeInGb" .= _cdfsSizeInGb)])
instance ToPath CreateDiskFromSnapshot where
toPath = const "/"
instance ToQuery CreateDiskFromSnapshot where
toQuery = const mempty
data CreateDiskFromSnapshotResponse = CreateDiskFromSnapshotResponse'
{ _cdfsrsOperations :: !(Maybe [Operation])
, _cdfsrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createDiskFromSnapshotResponse
:: Int
-> CreateDiskFromSnapshotResponse
createDiskFromSnapshotResponse pResponseStatus_ =
CreateDiskFromSnapshotResponse'
{_cdfsrsOperations = Nothing, _cdfsrsResponseStatus = pResponseStatus_}
cdfsrsOperations :: Lens' CreateDiskFromSnapshotResponse [Operation]
cdfsrsOperations = lens _cdfsrsOperations (\ s a -> s{_cdfsrsOperations = a}) . _Default . _Coerce
cdfsrsResponseStatus :: Lens' CreateDiskFromSnapshotResponse Int
cdfsrsResponseStatus = lens _cdfsrsResponseStatus (\ s a -> s{_cdfsrsResponseStatus = a})
instance NFData CreateDiskFromSnapshotResponse where