module Network.AWS.AutoScaling.DetachInstances
(
DetachInstances
, detachInstances
, diAutoScalingGroupName
, diInstanceIds
, diShouldDecrementDesiredCapacity
, DetachInstancesResponse
, detachInstancesResponse
, dirActivities
) where
import Network.AWS.Prelude
import Network.AWS.Request.Query
import Network.AWS.AutoScaling.Types
import qualified GHC.Exts
data DetachInstances = DetachInstances
{ _diAutoScalingGroupName :: Text
, _diInstanceIds :: List "member" Text
, _diShouldDecrementDesiredCapacity :: Bool
} deriving (Eq, Ord, Show)
detachInstances :: Text
-> Bool
-> DetachInstances
detachInstances p1 p2 = DetachInstances
{ _diAutoScalingGroupName = p1
, _diShouldDecrementDesiredCapacity = p2
, _diInstanceIds = mempty
}
diAutoScalingGroupName :: Lens' DetachInstances Text
diAutoScalingGroupName =
lens _diAutoScalingGroupName (\s a -> s { _diAutoScalingGroupName = a })
diInstanceIds :: Lens' DetachInstances [Text]
diInstanceIds = lens _diInstanceIds (\s a -> s { _diInstanceIds = a }) . _List
diShouldDecrementDesiredCapacity :: Lens' DetachInstances Bool
diShouldDecrementDesiredCapacity =
lens _diShouldDecrementDesiredCapacity
(\s a -> s { _diShouldDecrementDesiredCapacity = a })
newtype DetachInstancesResponse = DetachInstancesResponse
{ _dirActivities :: List "member" Activity
} deriving (Eq, Show, Monoid, Semigroup)
instance GHC.Exts.IsList DetachInstancesResponse where
type Item DetachInstancesResponse = Activity
fromList = DetachInstancesResponse . GHC.Exts.fromList
toList = GHC.Exts.toList . _dirActivities
detachInstancesResponse :: DetachInstancesResponse
detachInstancesResponse = DetachInstancesResponse
{ _dirActivities = mempty
}
dirActivities :: Lens' DetachInstancesResponse [Activity]
dirActivities = lens _dirActivities (\s a -> s { _dirActivities = a }) . _List
instance ToPath DetachInstances where
toPath = const "/"
instance ToQuery DetachInstances where
toQuery DetachInstances{..} = mconcat
[ "AutoScalingGroupName" =? _diAutoScalingGroupName
, "InstanceIds" =? _diInstanceIds
, "ShouldDecrementDesiredCapacity" =? _diShouldDecrementDesiredCapacity
]
instance ToHeaders DetachInstances
instance AWSRequest DetachInstances where
type Sv DetachInstances = AutoScaling
type Rs DetachInstances = DetachInstancesResponse
request = post "DetachInstances"
response = xmlResponse
instance FromXML DetachInstancesResponse where
parseXML = withElement "DetachInstancesResult" $ \x -> DetachInstancesResponse
<$> x .@? "Activities" .!@ mempty