module Network.AWS.EC2.DescribeSpotPriceHistory
(
DescribeSpotPriceHistory
, describeSpotPriceHistory
, dsphAvailabilityZone
, dsphDryRun
, dsphEndTime
, dsphFilters
, dsphInstanceTypes
, dsphMaxResults
, dsphNextToken
, dsphProductDescriptions
, dsphStartTime
, DescribeSpotPriceHistoryResponse
, describeSpotPriceHistoryResponse
, dsphrNextToken
, dsphrSpotPriceHistory
) where
import Network.AWS.Prelude
import Network.AWS.Request.Query
import Network.AWS.EC2.Types
import qualified GHC.Exts
data DescribeSpotPriceHistory = DescribeSpotPriceHistory
{ _dsphAvailabilityZone :: Maybe Text
, _dsphDryRun :: Maybe Bool
, _dsphEndTime :: Maybe ISO8601
, _dsphFilters :: List "Filter" Filter
, _dsphInstanceTypes :: List "InstanceType" InstanceType
, _dsphMaxResults :: Maybe Int
, _dsphNextToken :: Maybe Text
, _dsphProductDescriptions :: List "ProductDescription" Text
, _dsphStartTime :: Maybe ISO8601
} deriving (Eq, Show)
describeSpotPriceHistory :: DescribeSpotPriceHistory
describeSpotPriceHistory = DescribeSpotPriceHistory
{ _dsphDryRun = Nothing
, _dsphStartTime = Nothing
, _dsphEndTime = Nothing
, _dsphInstanceTypes = mempty
, _dsphProductDescriptions = mempty
, _dsphFilters = mempty
, _dsphAvailabilityZone = Nothing
, _dsphMaxResults = Nothing
, _dsphNextToken = Nothing
}
dsphAvailabilityZone :: Lens' DescribeSpotPriceHistory (Maybe Text)
dsphAvailabilityZone =
lens _dsphAvailabilityZone (\s a -> s { _dsphAvailabilityZone = a })
dsphDryRun :: Lens' DescribeSpotPriceHistory (Maybe Bool)
dsphDryRun = lens _dsphDryRun (\s a -> s { _dsphDryRun = a })
dsphEndTime :: Lens' DescribeSpotPriceHistory (Maybe UTCTime)
dsphEndTime = lens _dsphEndTime (\s a -> s { _dsphEndTime = a }) . mapping _Time
dsphFilters :: Lens' DescribeSpotPriceHistory [Filter]
dsphFilters = lens _dsphFilters (\s a -> s { _dsphFilters = a }) . _List
dsphInstanceTypes :: Lens' DescribeSpotPriceHistory [InstanceType]
dsphInstanceTypes =
lens _dsphInstanceTypes (\s a -> s { _dsphInstanceTypes = a })
. _List
dsphMaxResults :: Lens' DescribeSpotPriceHistory (Maybe Int)
dsphMaxResults = lens _dsphMaxResults (\s a -> s { _dsphMaxResults = a })
dsphNextToken :: Lens' DescribeSpotPriceHistory (Maybe Text)
dsphNextToken = lens _dsphNextToken (\s a -> s { _dsphNextToken = a })
dsphProductDescriptions :: Lens' DescribeSpotPriceHistory [Text]
dsphProductDescriptions =
lens _dsphProductDescriptions (\s a -> s { _dsphProductDescriptions = a })
. _List
dsphStartTime :: Lens' DescribeSpotPriceHistory (Maybe UTCTime)
dsphStartTime = lens _dsphStartTime (\s a -> s { _dsphStartTime = a }) . mapping _Time
data DescribeSpotPriceHistoryResponse = DescribeSpotPriceHistoryResponse
{ _dsphrNextToken :: Maybe Text
, _dsphrSpotPriceHistory :: List "item" SpotPrice
} deriving (Eq, Show)
describeSpotPriceHistoryResponse :: DescribeSpotPriceHistoryResponse
describeSpotPriceHistoryResponse = DescribeSpotPriceHistoryResponse
{ _dsphrSpotPriceHistory = mempty
, _dsphrNextToken = Nothing
}
dsphrNextToken :: Lens' DescribeSpotPriceHistoryResponse (Maybe Text)
dsphrNextToken = lens _dsphrNextToken (\s a -> s { _dsphrNextToken = a })
dsphrSpotPriceHistory :: Lens' DescribeSpotPriceHistoryResponse [SpotPrice]
dsphrSpotPriceHistory =
lens _dsphrSpotPriceHistory (\s a -> s { _dsphrSpotPriceHistory = a })
. _List
instance ToPath DescribeSpotPriceHistory where
toPath = const "/"
instance ToQuery DescribeSpotPriceHistory where
toQuery DescribeSpotPriceHistory{..} = mconcat
[ "availabilityZone" =? _dsphAvailabilityZone
, "dryRun" =? _dsphDryRun
, "endTime" =? _dsphEndTime
, "Filter" `toQueryList` _dsphFilters
, "InstanceType" `toQueryList` _dsphInstanceTypes
, "maxResults" =? _dsphMaxResults
, "nextToken" =? _dsphNextToken
, "ProductDescription" `toQueryList` _dsphProductDescriptions
, "startTime" =? _dsphStartTime
]
instance ToHeaders DescribeSpotPriceHistory
instance AWSRequest DescribeSpotPriceHistory where
type Sv DescribeSpotPriceHistory = EC2
type Rs DescribeSpotPriceHistory = DescribeSpotPriceHistoryResponse
request = post "DescribeSpotPriceHistory"
response = xmlResponse
instance FromXML DescribeSpotPriceHistoryResponse where
parseXML x = DescribeSpotPriceHistoryResponse
<$> x .@? "nextToken"
<*> x .@? "spotPriceHistorySet" .!@ mempty
instance AWSPager DescribeSpotPriceHistory where
page rq rs
| stop (rq ^. dsphNextToken) = Nothing
| otherwise = (\x -> rq & dsphNextToken ?~ x)
<$> (rs ^. dsphrNextToken)