{-# 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.AllocateHosts
(
allocateHosts
, AllocateHosts
, ahClientToken
, ahAutoPlacement
, ahInstanceType
, ahQuantity
, ahAvailabilityZone
, allocateHostsResponse
, AllocateHostsResponse
, ahrsHostIds
, ahrsResponseStatus
) 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 AllocateHosts = AllocateHosts'
{ _ahClientToken :: !(Maybe Text)
, _ahAutoPlacement :: !(Maybe AutoPlacement)
, _ahInstanceType :: !Text
, _ahQuantity :: !Int
, _ahAvailabilityZone :: !Text
} deriving (Eq,Read,Show,Data,Typeable,Generic)
allocateHosts
:: Text
-> Int
-> Text
-> AllocateHosts
allocateHosts pInstanceType_ pQuantity_ pAvailabilityZone_ =
AllocateHosts'
{ _ahClientToken = Nothing
, _ahAutoPlacement = Nothing
, _ahInstanceType = pInstanceType_
, _ahQuantity = pQuantity_
, _ahAvailabilityZone = pAvailabilityZone_
}
ahClientToken :: Lens' AllocateHosts (Maybe Text)
ahClientToken = lens _ahClientToken (\ s a -> s{_ahClientToken = a});
ahAutoPlacement :: Lens' AllocateHosts (Maybe AutoPlacement)
ahAutoPlacement = lens _ahAutoPlacement (\ s a -> s{_ahAutoPlacement = a});
ahInstanceType :: Lens' AllocateHosts Text
ahInstanceType = lens _ahInstanceType (\ s a -> s{_ahInstanceType = a});
ahQuantity :: Lens' AllocateHosts Int
ahQuantity = lens _ahQuantity (\ s a -> s{_ahQuantity = a});
ahAvailabilityZone :: Lens' AllocateHosts Text
ahAvailabilityZone = lens _ahAvailabilityZone (\ s a -> s{_ahAvailabilityZone = a});
instance AWSRequest AllocateHosts where
type Rs AllocateHosts = AllocateHostsResponse
request = postQuery ec2
response
= receiveXML
(\ s h x ->
AllocateHostsResponse' <$>
(x .@? "hostIdSet" .!@ mempty >>=
may (parseXMLList "item"))
<*> (pure (fromEnum s)))
instance Hashable AllocateHosts
instance NFData AllocateHosts
instance ToHeaders AllocateHosts where
toHeaders = const mempty
instance ToPath AllocateHosts where
toPath = const "/"
instance ToQuery AllocateHosts where
toQuery AllocateHosts'{..}
= mconcat
["Action" =: ("AllocateHosts" :: ByteString),
"Version" =: ("2016-04-01" :: ByteString),
"ClientToken" =: _ahClientToken,
"AutoPlacement" =: _ahAutoPlacement,
"InstanceType" =: _ahInstanceType,
"Quantity" =: _ahQuantity,
"AvailabilityZone" =: _ahAvailabilityZone]
data AllocateHostsResponse = AllocateHostsResponse'
{ _ahrsHostIds :: !(Maybe [Text])
, _ahrsResponseStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
allocateHostsResponse
:: Int
-> AllocateHostsResponse
allocateHostsResponse pResponseStatus_ =
AllocateHostsResponse'
{ _ahrsHostIds = Nothing
, _ahrsResponseStatus = pResponseStatus_
}
ahrsHostIds :: Lens' AllocateHostsResponse [Text]
ahrsHostIds = lens _ahrsHostIds (\ s a -> s{_ahrsHostIds = a}) . _Default . _Coerce;
ahrsResponseStatus :: Lens' AllocateHostsResponse Int
ahrsResponseStatus = lens _ahrsResponseStatus (\ s a -> s{_ahrsResponseStatus = a});
instance NFData AllocateHostsResponse