{-# 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.AttachDisk
(
attachDisk
, AttachDisk
, adDiskName
, adInstanceName
, adDiskPath
, attachDiskResponse
, AttachDiskResponse
, adrsOperations
, adrsResponseStatus
) 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 AttachDisk = AttachDisk'
{ _adDiskName :: !Text
, _adInstanceName :: !Text
, _adDiskPath :: !Text
} deriving (Eq, Read, Show, Data, Typeable, Generic)
attachDisk
:: Text
-> Text
-> Text
-> AttachDisk
attachDisk pDiskName_ pInstanceName_ pDiskPath_ =
AttachDisk'
{ _adDiskName = pDiskName_
, _adInstanceName = pInstanceName_
, _adDiskPath = pDiskPath_
}
adDiskName :: Lens' AttachDisk Text
adDiskName = lens _adDiskName (\ s a -> s{_adDiskName = a})
adInstanceName :: Lens' AttachDisk Text
adInstanceName = lens _adInstanceName (\ s a -> s{_adInstanceName = a})
adDiskPath :: Lens' AttachDisk Text
adDiskPath = lens _adDiskPath (\ s a -> s{_adDiskPath = a})
instance AWSRequest AttachDisk where
type Rs AttachDisk = AttachDiskResponse
request = postJSON lightsail
response
= receiveJSON
(\ s h x ->
AttachDiskResponse' <$>
(x .?> "operations" .!@ mempty) <*>
(pure (fromEnum s)))
instance Hashable AttachDisk where
instance NFData AttachDisk where
instance ToHeaders AttachDisk where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("Lightsail_20161128.AttachDisk" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON AttachDisk where
toJSON AttachDisk'{..}
= object
(catMaybes
[Just ("diskName" .= _adDiskName),
Just ("instanceName" .= _adInstanceName),
Just ("diskPath" .= _adDiskPath)])
instance ToPath AttachDisk where
toPath = const "/"
instance ToQuery AttachDisk where
toQuery = const mempty
data AttachDiskResponse = AttachDiskResponse'
{ _adrsOperations :: !(Maybe [Operation])
, _adrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
attachDiskResponse
:: Int
-> AttachDiskResponse
attachDiskResponse pResponseStatus_ =
AttachDiskResponse'
{_adrsOperations = Nothing, _adrsResponseStatus = pResponseStatus_}
adrsOperations :: Lens' AttachDiskResponse [Operation]
adrsOperations = lens _adrsOperations (\ s a -> s{_adrsOperations = a}) . _Default . _Coerce
adrsResponseStatus :: Lens' AttachDiskResponse Int
adrsResponseStatus = lens _adrsResponseStatus (\ s a -> s{_adrsResponseStatus = a})
instance NFData AttachDiskResponse where