module Network.AWS.EC2.DescribeSpotPriceHistory
(
describeSpotPriceHistory
, DescribeSpotPriceHistory
, dsphInstanceTypes
, dsphStartTime
, dsphFilters
, dsphNextToken
, dsphAvailabilityZone
, dsphEndTime
, dsphProductDescriptions
, dsphDryRun
, dsphMaxResults
, describeSpotPriceHistoryResponse
, DescribeSpotPriceHistoryResponse
, dsphrsNextToken
, dsphrsSpotPriceHistory
, dsphrsResponseStatus
) where
import Network.AWS.EC2.Types
import Network.AWS.EC2.Types.Product
import Network.AWS.Pager
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data DescribeSpotPriceHistory = DescribeSpotPriceHistory'
{ _dsphInstanceTypes :: !(Maybe [InstanceType])
, _dsphStartTime :: !(Maybe ISO8601)
, _dsphFilters :: !(Maybe [Filter])
, _dsphNextToken :: !(Maybe Text)
, _dsphAvailabilityZone :: !(Maybe Text)
, _dsphEndTime :: !(Maybe ISO8601)
, _dsphProductDescriptions :: !(Maybe [Text])
, _dsphDryRun :: !(Maybe Bool)
, _dsphMaxResults :: !(Maybe Int)
} deriving (Eq,Read,Show,Data,Typeable,Generic)
describeSpotPriceHistory
:: DescribeSpotPriceHistory
describeSpotPriceHistory =
DescribeSpotPriceHistory'
{ _dsphInstanceTypes = Nothing
, _dsphStartTime = Nothing
, _dsphFilters = Nothing
, _dsphNextToken = Nothing
, _dsphAvailabilityZone = Nothing
, _dsphEndTime = Nothing
, _dsphProductDescriptions = Nothing
, _dsphDryRun = Nothing
, _dsphMaxResults = Nothing
}
dsphInstanceTypes :: Lens' DescribeSpotPriceHistory [InstanceType]
dsphInstanceTypes = lens _dsphInstanceTypes (\ s a -> s{_dsphInstanceTypes = a}) . _Default . _Coerce;
dsphStartTime :: Lens' DescribeSpotPriceHistory (Maybe UTCTime)
dsphStartTime = lens _dsphStartTime (\ s a -> s{_dsphStartTime = a}) . mapping _Time;
dsphFilters :: Lens' DescribeSpotPriceHistory [Filter]
dsphFilters = lens _dsphFilters (\ s a -> s{_dsphFilters = a}) . _Default . _Coerce;
dsphNextToken :: Lens' DescribeSpotPriceHistory (Maybe Text)
dsphNextToken = lens _dsphNextToken (\ s a -> s{_dsphNextToken = a});
dsphAvailabilityZone :: Lens' DescribeSpotPriceHistory (Maybe Text)
dsphAvailabilityZone = lens _dsphAvailabilityZone (\ s a -> s{_dsphAvailabilityZone = a});
dsphEndTime :: Lens' DescribeSpotPriceHistory (Maybe UTCTime)
dsphEndTime = lens _dsphEndTime (\ s a -> s{_dsphEndTime = a}) . mapping _Time;
dsphProductDescriptions :: Lens' DescribeSpotPriceHistory [Text]
dsphProductDescriptions = lens _dsphProductDescriptions (\ s a -> s{_dsphProductDescriptions = a}) . _Default . _Coerce;
dsphDryRun :: Lens' DescribeSpotPriceHistory (Maybe Bool)
dsphDryRun = lens _dsphDryRun (\ s a -> s{_dsphDryRun = a});
dsphMaxResults :: Lens' DescribeSpotPriceHistory (Maybe Int)
dsphMaxResults = lens _dsphMaxResults (\ s a -> s{_dsphMaxResults = a});
instance AWSPager DescribeSpotPriceHistory where
page rq rs
| stop (rs ^. dsphrsNextToken) = Nothing
| stop (rs ^. dsphrsSpotPriceHistory) = Nothing
| otherwise =
Just $ rq & dsphNextToken .~ rs ^. dsphrsNextToken
instance AWSRequest DescribeSpotPriceHistory where
type Rs DescribeSpotPriceHistory =
DescribeSpotPriceHistoryResponse
request = postQuery eC2
response
= receiveXML
(\ s h x ->
DescribeSpotPriceHistoryResponse' <$>
(x .@? "nextToken") <*>
(x .@? "spotPriceHistorySet" .!@ mempty >>=
may (parseXMLList "item"))
<*> (pure (fromEnum s)))
instance ToHeaders DescribeSpotPriceHistory where
toHeaders = const mempty
instance ToPath DescribeSpotPriceHistory where
toPath = const "/"
instance ToQuery DescribeSpotPriceHistory where
toQuery DescribeSpotPriceHistory'{..}
= mconcat
["Action" =:
("DescribeSpotPriceHistory" :: ByteString),
"Version" =: ("2015-10-01" :: ByteString),
toQuery
(toQueryList "InstanceType" <$> _dsphInstanceTypes),
"StartTime" =: _dsphStartTime,
toQuery (toQueryList "Filter" <$> _dsphFilters),
"NextToken" =: _dsphNextToken,
"AvailabilityZone" =: _dsphAvailabilityZone,
"EndTime" =: _dsphEndTime,
toQuery
(toQueryList "ProductDescription" <$>
_dsphProductDescriptions),
"DryRun" =: _dsphDryRun,
"MaxResults" =: _dsphMaxResults]
data DescribeSpotPriceHistoryResponse = DescribeSpotPriceHistoryResponse'
{ _dsphrsNextToken :: !(Maybe Text)
, _dsphrsSpotPriceHistory :: !(Maybe [SpotPrice])
, _dsphrsResponseStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
describeSpotPriceHistoryResponse
:: Int
-> DescribeSpotPriceHistoryResponse
describeSpotPriceHistoryResponse pResponseStatus_ =
DescribeSpotPriceHistoryResponse'
{ _dsphrsNextToken = Nothing
, _dsphrsSpotPriceHistory = Nothing
, _dsphrsResponseStatus = pResponseStatus_
}
dsphrsNextToken :: Lens' DescribeSpotPriceHistoryResponse (Maybe Text)
dsphrsNextToken = lens _dsphrsNextToken (\ s a -> s{_dsphrsNextToken = a});
dsphrsSpotPriceHistory :: Lens' DescribeSpotPriceHistoryResponse [SpotPrice]
dsphrsSpotPriceHistory = lens _dsphrsSpotPriceHistory (\ s a -> s{_dsphrsSpotPriceHistory = a}) . _Default . _Coerce;
dsphrsResponseStatus :: Lens' DescribeSpotPriceHistoryResponse Int
dsphrsResponseStatus = lens _dsphrsResponseStatus (\ s a -> s{_dsphrsResponseStatus = a});