{-# 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.GetHostReservationPurchasePreview
(
getHostReservationPurchasePreview
, GetHostReservationPurchasePreview
, ghrppHostIdSet
, ghrppOfferingId
, getHostReservationPurchasePreviewResponse
, GetHostReservationPurchasePreviewResponse
, ghrpprsCurrencyCode
, ghrpprsTotalHourlyPrice
, ghrpprsTotalUpfrontPrice
, ghrpprsPurchase
, ghrpprsResponseStatus
) 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 GetHostReservationPurchasePreview = GetHostReservationPurchasePreview'
{ _ghrppHostIdSet :: ![Text]
, _ghrppOfferingId :: !Text
} deriving (Eq, Read, Show, Data, Typeable, Generic)
getHostReservationPurchasePreview
:: Text
-> GetHostReservationPurchasePreview
getHostReservationPurchasePreview pOfferingId_ =
GetHostReservationPurchasePreview'
{_ghrppHostIdSet = mempty, _ghrppOfferingId = pOfferingId_}
ghrppHostIdSet :: Lens' GetHostReservationPurchasePreview [Text]
ghrppHostIdSet = lens _ghrppHostIdSet (\ s a -> s{_ghrppHostIdSet = a}) . _Coerce
ghrppOfferingId :: Lens' GetHostReservationPurchasePreview Text
ghrppOfferingId = lens _ghrppOfferingId (\ s a -> s{_ghrppOfferingId = a})
instance AWSRequest GetHostReservationPurchasePreview
where
type Rs GetHostReservationPurchasePreview =
GetHostReservationPurchasePreviewResponse
request = postQuery ec2
response
= receiveXML
(\ s h x ->
GetHostReservationPurchasePreviewResponse' <$>
(x .@? "currencyCode") <*> (x .@? "totalHourlyPrice")
<*> (x .@? "totalUpfrontPrice")
<*>
(x .@? "purchase" .!@ mempty >>=
may (parseXMLList "item"))
<*> (pure (fromEnum s)))
instance Hashable GetHostReservationPurchasePreview
where
instance NFData GetHostReservationPurchasePreview
where
instance ToHeaders GetHostReservationPurchasePreview
where
toHeaders = const mempty
instance ToPath GetHostReservationPurchasePreview
where
toPath = const "/"
instance ToQuery GetHostReservationPurchasePreview
where
toQuery GetHostReservationPurchasePreview'{..}
= mconcat
["Action" =:
("GetHostReservationPurchasePreview" :: ByteString),
"Version" =: ("2016-11-15" :: ByteString),
toQueryList "HostIdSet" _ghrppHostIdSet,
"OfferingId" =: _ghrppOfferingId]
data GetHostReservationPurchasePreviewResponse = GetHostReservationPurchasePreviewResponse'
{ _ghrpprsCurrencyCode :: !(Maybe CurrencyCodeValues)
, _ghrpprsTotalHourlyPrice :: !(Maybe Text)
, _ghrpprsTotalUpfrontPrice :: !(Maybe Text)
, _ghrpprsPurchase :: !(Maybe [Purchase])
, _ghrpprsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
getHostReservationPurchasePreviewResponse
:: Int
-> GetHostReservationPurchasePreviewResponse
getHostReservationPurchasePreviewResponse pResponseStatus_ =
GetHostReservationPurchasePreviewResponse'
{ _ghrpprsCurrencyCode = Nothing
, _ghrpprsTotalHourlyPrice = Nothing
, _ghrpprsTotalUpfrontPrice = Nothing
, _ghrpprsPurchase = Nothing
, _ghrpprsResponseStatus = pResponseStatus_
}
ghrpprsCurrencyCode :: Lens' GetHostReservationPurchasePreviewResponse (Maybe CurrencyCodeValues)
ghrpprsCurrencyCode = lens _ghrpprsCurrencyCode (\ s a -> s{_ghrpprsCurrencyCode = a})
ghrpprsTotalHourlyPrice :: Lens' GetHostReservationPurchasePreviewResponse (Maybe Text)
ghrpprsTotalHourlyPrice = lens _ghrpprsTotalHourlyPrice (\ s a -> s{_ghrpprsTotalHourlyPrice = a})
ghrpprsTotalUpfrontPrice :: Lens' GetHostReservationPurchasePreviewResponse (Maybe Text)
ghrpprsTotalUpfrontPrice = lens _ghrpprsTotalUpfrontPrice (\ s a -> s{_ghrpprsTotalUpfrontPrice = a})
ghrpprsPurchase :: Lens' GetHostReservationPurchasePreviewResponse [Purchase]
ghrpprsPurchase = lens _ghrpprsPurchase (\ s a -> s{_ghrpprsPurchase = a}) . _Default . _Coerce
ghrpprsResponseStatus :: Lens' GetHostReservationPurchasePreviewResponse Int
ghrpprsResponseStatus = lens _ghrpprsResponseStatus (\ s a -> s{_ghrpprsResponseStatus = a})
instance NFData
GetHostReservationPurchasePreviewResponse
where