module Network.AWS.AutoScaling.Types
    (
    
      AutoScaling
    
    , RESTError
    
    , ns
    
    , TagDescription
    , tagDescription
    , tdKey
    , tdPropagateAtLaunch
    , tdResourceId
    , tdResourceType
    , tdValue
    
    , Tag
    , tag
    , tagKey
    , tagPropagateAtLaunch
    , tagResourceId
    , tagResourceType
    , tagValue
    
    , NotificationConfiguration
    , notificationConfiguration
    , ncAutoScalingGroupName
    , ncNotificationType
    , ncTopicARN
    
    , BlockDeviceMapping
    , blockDeviceMapping
    , bdmDeviceName
    , bdmEbs
    , bdmNoDevice
    , bdmVirtualName
    
    , LaunchConfiguration
    , launchConfiguration
    , lcAssociatePublicIpAddress
    , lcBlockDeviceMappings
    , lcCreatedTime
    , lcEbsOptimized
    , lcIamInstanceProfile
    , lcImageId
    , lcInstanceMonitoring
    , lcInstanceType
    , lcKernelId
    , lcKeyName
    , lcLaunchConfigurationARN
    , lcLaunchConfigurationName
    , lcPlacementTenancy
    , lcRamdiskId
    , lcSecurityGroups
    , lcSpotPrice
    , lcUserData
    
    , AutoScalingGroup
    , autoScalingGroup
    , asgAutoScalingGroupARN
    , asgAutoScalingGroupName
    , asgAvailabilityZones
    , asgCreatedTime
    , asgDefaultCooldown
    , asgDesiredCapacity
    , asgEnabledMetrics
    , asgHealthCheckGracePeriod
    , asgHealthCheckType
    , asgInstances
    , asgLaunchConfigurationName
    , asgLoadBalancerNames
    , asgMaxSize
    , asgMinSize
    , asgPlacementGroup
    , asgStatus
    , asgSuspendedProcesses
    , asgTags
    , asgTerminationPolicies
    , asgVPCZoneIdentifier
    
    , ScalingPolicy
    , scalingPolicy
    , sp1AdjustmentType
    , sp1Alarms
    , sp1AutoScalingGroupName
    , sp1Cooldown
    , sp1MinAdjustmentStep
    , sp1PolicyARN
    , sp1PolicyName
    , sp1ScalingAdjustment
    
    , InstanceMonitoring
    , instanceMonitoring
    , imEnabled
    
    , ScheduledUpdateGroupAction
    , scheduledUpdateGroupAction
    , sugaAutoScalingGroupName
    , sugaDesiredCapacity
    , sugaEndTime
    , sugaMaxSize
    , sugaMinSize
    , sugaRecurrence
    , sugaScheduledActionARN
    , sugaScheduledActionName
    , sugaStartTime
    , sugaTime
    
    , ScalingProcessQuery
    , scalingProcessQuery
    , spqAutoScalingGroupName
    , spqScalingProcesses
    
    , Ebs
    , ebs
    , ebsDeleteOnTermination
    , ebsIops
    , ebsSnapshotId
    , ebsVolumeSize
    , ebsVolumeType
    
    , AdjustmentType
    , adjustmentType
    , atAdjustmentType
    
    , MetricCollectionType
    , metricCollectionType
    , mctMetric
    
    , LifecycleHook
    , lifecycleHook
    , lhAutoScalingGroupName
    , lhDefaultResult
    , lhGlobalTimeout
    , lhHeartbeatTimeout
    , lhLifecycleHookName
    , lhLifecycleTransition
    , lhNotificationMetadata
    , lhNotificationTargetARN
    , lhRoleARN
    
    , Activity
    , activity
    , aActivityId
    , aAutoScalingGroupName
    , aCause
    , aDescription
    , aDetails
    , aEndTime
    , aProgress
    , aStartTime
    , aStatusCode
    , aStatusMessage
    
    , SuspendedProcess
    , suspendedProcess
    , spProcessName
    , spSuspensionReason
    
    , MetricGranularityType
    , metricGranularityType
    , mgtGranularity
    
    , Filter
    , filter'
    , fName
    , fValues
    
    , ProcessType
    , processType
    , ptProcessName
    
    , Alarm
    , alarm
    , aAlarmARN
    , aAlarmName
    
    , EnabledMetric
    , enabledMetric
    , emGranularity
    , emMetric
    
    , Instance
    , instance'
    , iAvailabilityZone
    , iHealthStatus
    , iInstanceId
    , iLaunchConfigurationName
    , iLifecycleState
    
    , LifecycleState (..)
    
    , AutoScalingInstanceDetails
    , autoScalingInstanceDetails
    , asidAutoScalingGroupName
    , asidAvailabilityZone
    , asidHealthStatus
    , asidInstanceId
    , asidLaunchConfigurationName
    , asidLifecycleState
    
    , ScalingActivityStatusCode (..)
    ) where
import Network.AWS.Prelude
import Network.AWS.Signing
import qualified GHC.Exts
data AutoScaling
instance AWSService AutoScaling where
    type Sg AutoScaling = V4
    type Er AutoScaling = RESTError
    service = service'
      where
        service' :: Service AutoScaling
        service' = Service
            { _svcAbbrev       = "AutoScaling"
            , _svcPrefix       = "autoscaling"
            , _svcVersion      = "2011-01-01"
            , _svcTargetPrefix = Nothing
            , _svcJSONVersion  = Nothing
            , _svcHandle       = handle
            , _svcRetry        = retry
            }
        handle :: Status
               -> Maybe (LazyByteString -> ServiceError RESTError)
        handle = restError statusSuccess service'
        retry :: Retry AutoScaling
        retry = Exponential
            { _retryBase     = 0.05
            , _retryGrowth   = 2
            , _retryAttempts = 5
            , _retryCheck    = check
            }
        check :: Status
              -> RESTError
              -> Bool
        check (statusCode -> s) (awsErrorCode -> e)
            | s == 400 && "Throttling" == e = True 
            | s == 500  = True 
            | s == 509  = True 
            | s == 503  = True 
            | otherwise = False
ns :: Text
ns = "http://autoscaling.amazonaws.com/doc/2011-01-01/"
data TagDescription = TagDescription
    { _tdKey               :: Text
    , _tdPropagateAtLaunch :: Bool
    , _tdResourceId        :: Text
    , _tdResourceType      :: Text
    , _tdValue             :: Text
    } deriving (Eq, Ord, Show)
tagDescription :: Text 
               -> Text 
               -> Text 
               -> Text 
               -> Bool 
               -> TagDescription
tagDescription p1 p2 p3 p4 p5 = TagDescription
    { _tdResourceId        = p1
    , _tdResourceType      = p2
    , _tdKey               = p3
    , _tdValue             = p4
    , _tdPropagateAtLaunch = p5
    }
tdKey :: Lens' TagDescription Text
tdKey = lens _tdKey (\s a -> s { _tdKey = a })
tdPropagateAtLaunch :: Lens' TagDescription Bool
tdPropagateAtLaunch =
    lens _tdPropagateAtLaunch (\s a -> s { _tdPropagateAtLaunch = a })
tdResourceId :: Lens' TagDescription Text
tdResourceId = lens _tdResourceId (\s a -> s { _tdResourceId = a })
tdResourceType :: Lens' TagDescription Text
tdResourceType = lens _tdResourceType (\s a -> s { _tdResourceType = a })
tdValue :: Lens' TagDescription Text
tdValue = lens _tdValue (\s a -> s { _tdValue = a })
instance FromXML TagDescription where
    parseXML x = TagDescription
        <$> x .@  "Key"
        <*> x .@  "PropagateAtLaunch"
        <*> x .@  "ResourceId"
        <*> x .@  "ResourceType"
        <*> x .@  "Value"
instance ToQuery TagDescription where
    toQuery TagDescription{..} = mconcat
        [ "Key"               =? _tdKey
        , "PropagateAtLaunch" =? _tdPropagateAtLaunch
        , "ResourceId"        =? _tdResourceId
        , "ResourceType"      =? _tdResourceType
        , "Value"             =? _tdValue
        ]
data Tag = Tag
    { _tagKey               :: Text
    , _tagPropagateAtLaunch :: Bool
    , _tagResourceId        :: Text
    , _tagResourceType      :: Text
    , _tagValue             :: Text
    } deriving (Eq, Ord, Show)
tag :: Text 
    -> Text 
    -> Text 
    -> Text 
    -> Bool 
    -> Tag
tag p1 p2 p3 p4 p5 = Tag
    { _tagResourceId        = p1
    , _tagResourceType      = p2
    , _tagKey               = p3
    , _tagValue             = p4
    , _tagPropagateAtLaunch = p5
    }
tagKey :: Lens' Tag Text
tagKey = lens _tagKey (\s a -> s { _tagKey = a })
tagPropagateAtLaunch :: Lens' Tag Bool
tagPropagateAtLaunch =
    lens _tagPropagateAtLaunch (\s a -> s { _tagPropagateAtLaunch = a })
tagResourceId :: Lens' Tag Text
tagResourceId = lens _tagResourceId (\s a -> s { _tagResourceId = a })
tagResourceType :: Lens' Tag Text
tagResourceType = lens _tagResourceType (\s a -> s { _tagResourceType = a })
tagValue :: Lens' Tag Text
tagValue = lens _tagValue (\s a -> s { _tagValue = a })
instance FromXML Tag where
    parseXML x = Tag
        <$> x .@  "Key"
        <*> x .@  "PropagateAtLaunch"
        <*> x .@  "ResourceId"
        <*> x .@  "ResourceType"
        <*> x .@  "Value"
instance ToQuery Tag where
    toQuery Tag{..} = mconcat
        [ "Key"               =? _tagKey
        , "PropagateAtLaunch" =? _tagPropagateAtLaunch
        , "ResourceId"        =? _tagResourceId
        , "ResourceType"      =? _tagResourceType
        , "Value"             =? _tagValue
        ]
data NotificationConfiguration = NotificationConfiguration
    { _ncAutoScalingGroupName :: Maybe Text
    , _ncNotificationType     :: Maybe Text
    , _ncTopicARN             :: Maybe Text
    } deriving (Eq, Ord, Show)
notificationConfiguration :: NotificationConfiguration
notificationConfiguration = NotificationConfiguration
    { _ncAutoScalingGroupName = Nothing
    , _ncTopicARN             = Nothing
    , _ncNotificationType     = Nothing
    }
ncAutoScalingGroupName :: Lens' NotificationConfiguration (Maybe Text)
ncAutoScalingGroupName =
    lens _ncAutoScalingGroupName (\s a -> s { _ncAutoScalingGroupName = a })
ncNotificationType :: Lens' NotificationConfiguration (Maybe Text)
ncNotificationType =
    lens _ncNotificationType (\s a -> s { _ncNotificationType = a })
ncTopicARN :: Lens' NotificationConfiguration (Maybe Text)
ncTopicARN = lens _ncTopicARN (\s a -> s { _ncTopicARN = a })
instance FromXML NotificationConfiguration where
    parseXML x = NotificationConfiguration
        <$> x .@? "AutoScalingGroupName"
        <*> x .@? "NotificationType"
        <*> x .@? "TopicARN"
instance ToQuery NotificationConfiguration where
    toQuery NotificationConfiguration{..} = mconcat
        [ "AutoScalingGroupName" =? _ncAutoScalingGroupName
        , "NotificationType"     =? _ncNotificationType
        , "TopicARN"             =? _ncTopicARN
        ]
data BlockDeviceMapping = BlockDeviceMapping
    { _bdmDeviceName  :: Text
    , _bdmEbs         :: Maybe Ebs
    , _bdmNoDevice    :: Maybe Bool
    , _bdmVirtualName :: Maybe Text
    } deriving (Eq, Show)
blockDeviceMapping :: Text 
                   -> BlockDeviceMapping
blockDeviceMapping p1 = BlockDeviceMapping
    { _bdmDeviceName  = p1
    , _bdmVirtualName = Nothing
    , _bdmEbs         = Nothing
    , _bdmNoDevice    = Nothing
    }
bdmDeviceName :: Lens' BlockDeviceMapping Text
bdmDeviceName = lens _bdmDeviceName (\s a -> s { _bdmDeviceName = a })
bdmEbs :: Lens' BlockDeviceMapping (Maybe Ebs)
bdmEbs = lens _bdmEbs (\s a -> s { _bdmEbs = a })
bdmNoDevice :: Lens' BlockDeviceMapping (Maybe Bool)
bdmNoDevice = lens _bdmNoDevice (\s a -> s { _bdmNoDevice = a })
bdmVirtualName :: Lens' BlockDeviceMapping (Maybe Text)
bdmVirtualName = lens _bdmVirtualName (\s a -> s { _bdmVirtualName = a })
instance FromXML BlockDeviceMapping where
    parseXML x = BlockDeviceMapping
        <$> x .@  "DeviceName"
        <*> x .@? "Ebs"
        <*> x .@? "NoDevice"
        <*> x .@? "VirtualName"
instance ToQuery BlockDeviceMapping where
    toQuery BlockDeviceMapping{..} = mconcat
        [ "DeviceName"  =? _bdmDeviceName
        , "Ebs"         =? _bdmEbs
        , "NoDevice"    =? _bdmNoDevice
        , "VirtualName" =? _bdmVirtualName
        ]
data LaunchConfiguration = LaunchConfiguration
    { _lcAssociatePublicIpAddress :: Maybe Bool
    , _lcBlockDeviceMappings      :: List "member" BlockDeviceMapping
    , _lcCreatedTime              :: ISO8601
    , _lcEbsOptimized             :: Maybe Bool
    , _lcIamInstanceProfile       :: Maybe Text
    , _lcImageId                  :: Text
    , _lcInstanceMonitoring       :: Maybe InstanceMonitoring
    , _lcInstanceType             :: Text
    , _lcKernelId                 :: Maybe Text
    , _lcKeyName                  :: Maybe Text
    , _lcLaunchConfigurationARN   :: Maybe Text
    , _lcLaunchConfigurationName  :: Text
    , _lcPlacementTenancy         :: Maybe Text
    , _lcRamdiskId                :: Maybe Text
    , _lcSecurityGroups           :: List "member" Text
    , _lcSpotPrice                :: Maybe Text
    , _lcUserData                 :: Maybe Text
    } deriving (Eq, Show)
launchConfiguration :: Text 
                    -> Text 
                    -> Text 
                    -> UTCTime 
                    -> LaunchConfiguration
launchConfiguration p1 p2 p3 p4 = LaunchConfiguration
    { _lcLaunchConfigurationName  = p1
    , _lcImageId                  = p2
    , _lcInstanceType             = p3
    , _lcCreatedTime              = withIso _Time (const id) p4
    , _lcLaunchConfigurationARN   = Nothing
    , _lcKeyName                  = Nothing
    , _lcSecurityGroups           = mempty
    , _lcUserData                 = Nothing
    , _lcKernelId                 = Nothing
    , _lcRamdiskId                = Nothing
    , _lcBlockDeviceMappings      = mempty
    , _lcInstanceMonitoring       = Nothing
    , _lcSpotPrice                = Nothing
    , _lcIamInstanceProfile       = Nothing
    , _lcEbsOptimized             = Nothing
    , _lcAssociatePublicIpAddress = Nothing
    , _lcPlacementTenancy         = Nothing
    }
lcAssociatePublicIpAddress :: Lens' LaunchConfiguration (Maybe Bool)
lcAssociatePublicIpAddress =
    lens _lcAssociatePublicIpAddress
        (\s a -> s { _lcAssociatePublicIpAddress = a })
lcBlockDeviceMappings :: Lens' LaunchConfiguration [BlockDeviceMapping]
lcBlockDeviceMappings =
    lens _lcBlockDeviceMappings (\s a -> s { _lcBlockDeviceMappings = a })
        . _List
lcCreatedTime :: Lens' LaunchConfiguration UTCTime
lcCreatedTime = lens _lcCreatedTime (\s a -> s { _lcCreatedTime = a }) . _Time
lcEbsOptimized :: Lens' LaunchConfiguration (Maybe Bool)
lcEbsOptimized = lens _lcEbsOptimized (\s a -> s { _lcEbsOptimized = a })
lcIamInstanceProfile :: Lens' LaunchConfiguration (Maybe Text)
lcIamInstanceProfile =
    lens _lcIamInstanceProfile (\s a -> s { _lcIamInstanceProfile = a })
lcImageId :: Lens' LaunchConfiguration Text
lcImageId = lens _lcImageId (\s a -> s { _lcImageId = a })
lcInstanceMonitoring :: Lens' LaunchConfiguration (Maybe InstanceMonitoring)
lcInstanceMonitoring =
    lens _lcInstanceMonitoring (\s a -> s { _lcInstanceMonitoring = a })
lcInstanceType :: Lens' LaunchConfiguration Text
lcInstanceType = lens _lcInstanceType (\s a -> s { _lcInstanceType = a })
lcKernelId :: Lens' LaunchConfiguration (Maybe Text)
lcKernelId = lens _lcKernelId (\s a -> s { _lcKernelId = a })
lcKeyName :: Lens' LaunchConfiguration (Maybe Text)
lcKeyName = lens _lcKeyName (\s a -> s { _lcKeyName = a })
lcLaunchConfigurationARN :: Lens' LaunchConfiguration (Maybe Text)
lcLaunchConfigurationARN =
    lens _lcLaunchConfigurationARN
        (\s a -> s { _lcLaunchConfigurationARN = a })
lcLaunchConfigurationName :: Lens' LaunchConfiguration Text
lcLaunchConfigurationName =
    lens _lcLaunchConfigurationName
        (\s a -> s { _lcLaunchConfigurationName = a })
lcPlacementTenancy :: Lens' LaunchConfiguration (Maybe Text)
lcPlacementTenancy =
    lens _lcPlacementTenancy (\s a -> s { _lcPlacementTenancy = a })
lcRamdiskId :: Lens' LaunchConfiguration (Maybe Text)
lcRamdiskId = lens _lcRamdiskId (\s a -> s { _lcRamdiskId = a })
lcSecurityGroups :: Lens' LaunchConfiguration [Text]
lcSecurityGroups = lens _lcSecurityGroups (\s a -> s { _lcSecurityGroups = a }) . _List
lcSpotPrice :: Lens' LaunchConfiguration (Maybe Text)
lcSpotPrice = lens _lcSpotPrice (\s a -> s { _lcSpotPrice = a })
lcUserData :: Lens' LaunchConfiguration (Maybe Text)
lcUserData = lens _lcUserData (\s a -> s { _lcUserData = a })
instance FromXML LaunchConfiguration where
    parseXML x = LaunchConfiguration
        <$> x .@? "AssociatePublicIpAddress"
        <*> x .@? "BlockDeviceMappings" .!@ mempty
        <*> x .@  "CreatedTime"
        <*> x .@? "EbsOptimized"
        <*> x .@? "IamInstanceProfile"
        <*> x .@  "ImageId"
        <*> x .@? "InstanceMonitoring"
        <*> x .@  "InstanceType"
        <*> x .@? "KernelId"
        <*> x .@? "KeyName"
        <*> x .@? "LaunchConfigurationARN"
        <*> x .@  "LaunchConfigurationName"
        <*> x .@? "PlacementTenancy"
        <*> x .@? "RamdiskId"
        <*> x .@? "SecurityGroups" .!@ mempty
        <*> x .@? "SpotPrice"
        <*> x .@? "UserData"
instance ToQuery LaunchConfiguration where
    toQuery LaunchConfiguration{..} = mconcat
        [ "AssociatePublicIpAddress" =? _lcAssociatePublicIpAddress
        , "BlockDeviceMappings"      =? _lcBlockDeviceMappings
        , "CreatedTime"              =? _lcCreatedTime
        , "EbsOptimized"             =? _lcEbsOptimized
        , "IamInstanceProfile"       =? _lcIamInstanceProfile
        , "ImageId"                  =? _lcImageId
        , "InstanceMonitoring"       =? _lcInstanceMonitoring
        , "InstanceType"             =? _lcInstanceType
        , "KernelId"                 =? _lcKernelId
        , "KeyName"                  =? _lcKeyName
        , "LaunchConfigurationARN"   =? _lcLaunchConfigurationARN
        , "LaunchConfigurationName"  =? _lcLaunchConfigurationName
        , "PlacementTenancy"         =? _lcPlacementTenancy
        , "RamdiskId"                =? _lcRamdiskId
        , "SecurityGroups"           =? _lcSecurityGroups
        , "SpotPrice"                =? _lcSpotPrice
        , "UserData"                 =? _lcUserData
        ]
data AutoScalingGroup = AutoScalingGroup
    { _asgAutoScalingGroupARN     :: Maybe Text
    , _asgAutoScalingGroupName    :: Text
    , _asgAvailabilityZones       :: List1 "member" Text
    , _asgCreatedTime             :: ISO8601
    , _asgDefaultCooldown         :: Int
    , _asgDesiredCapacity         :: Int
    , _asgEnabledMetrics          :: List "member" EnabledMetric
    , _asgHealthCheckGracePeriod  :: Maybe Int
    , _asgHealthCheckType         :: Text
    , _asgInstances               :: List "member" Instance
    , _asgLaunchConfigurationName :: Text
    , _asgLoadBalancerNames       :: List "member" Text
    , _asgMaxSize                 :: Int
    , _asgMinSize                 :: Int
    , _asgPlacementGroup          :: Maybe Text
    , _asgStatus                  :: Maybe Text
    , _asgSuspendedProcesses      :: List "member" SuspendedProcess
    , _asgTags                    :: List "member" TagDescription
    , _asgTerminationPolicies     :: List "member" Text
    , _asgVPCZoneIdentifier       :: Maybe Text
    } deriving (Eq, Show)
autoScalingGroup :: Text 
                 -> Text 
                 -> Int 
                 -> Int 
                 -> Int 
                 -> Int 
                 -> NonEmpty Text 
                 -> Text 
                 -> UTCTime 
                 -> AutoScalingGroup
autoScalingGroup p1 p2 p3 p4 p5 p6 p7 p8 p9 = AutoScalingGroup
    { _asgAutoScalingGroupName    = p1
    , _asgLaunchConfigurationName = p2
    , _asgMinSize                 = p3
    , _asgMaxSize                 = p4
    , _asgDesiredCapacity         = p5
    , _asgDefaultCooldown         = p6
    , _asgAvailabilityZones       = withIso _List1 (const id) p7
    , _asgHealthCheckType         = p8
    , _asgCreatedTime             = withIso _Time (const id) p9
    , _asgAutoScalingGroupARN     = Nothing
    , _asgLoadBalancerNames       = mempty
    , _asgHealthCheckGracePeriod  = Nothing
    , _asgInstances               = mempty
    , _asgSuspendedProcesses      = mempty
    , _asgPlacementGroup          = Nothing
    , _asgVPCZoneIdentifier       = Nothing
    , _asgEnabledMetrics          = mempty
    , _asgStatus                  = Nothing
    , _asgTags                    = mempty
    , _asgTerminationPolicies     = mempty
    }
asgAutoScalingGroupARN :: Lens' AutoScalingGroup (Maybe Text)
asgAutoScalingGroupARN =
    lens _asgAutoScalingGroupARN (\s a -> s { _asgAutoScalingGroupARN = a })
asgAutoScalingGroupName :: Lens' AutoScalingGroup Text
asgAutoScalingGroupName =
    lens _asgAutoScalingGroupName (\s a -> s { _asgAutoScalingGroupName = a })
asgAvailabilityZones :: Lens' AutoScalingGroup (NonEmpty Text)
asgAvailabilityZones =
    lens _asgAvailabilityZones (\s a -> s { _asgAvailabilityZones = a })
        . _List1
asgCreatedTime :: Lens' AutoScalingGroup UTCTime
asgCreatedTime = lens _asgCreatedTime (\s a -> s { _asgCreatedTime = a }) . _Time
asgDefaultCooldown :: Lens' AutoScalingGroup Int
asgDefaultCooldown =
    lens _asgDefaultCooldown (\s a -> s { _asgDefaultCooldown = a })
asgDesiredCapacity :: Lens' AutoScalingGroup Int
asgDesiredCapacity =
    lens _asgDesiredCapacity (\s a -> s { _asgDesiredCapacity = a })
asgEnabledMetrics :: Lens' AutoScalingGroup [EnabledMetric]
asgEnabledMetrics =
    lens _asgEnabledMetrics (\s a -> s { _asgEnabledMetrics = a })
        . _List
asgHealthCheckGracePeriod :: Lens' AutoScalingGroup (Maybe Int)
asgHealthCheckGracePeriod =
    lens _asgHealthCheckGracePeriod
        (\s a -> s { _asgHealthCheckGracePeriod = a })
asgHealthCheckType :: Lens' AutoScalingGroup Text
asgHealthCheckType =
    lens _asgHealthCheckType (\s a -> s { _asgHealthCheckType = a })
asgInstances :: Lens' AutoScalingGroup [Instance]
asgInstances = lens _asgInstances (\s a -> s { _asgInstances = a }) . _List
asgLaunchConfigurationName :: Lens' AutoScalingGroup Text
asgLaunchConfigurationName =
    lens _asgLaunchConfigurationName
        (\s a -> s { _asgLaunchConfigurationName = a })
asgLoadBalancerNames :: Lens' AutoScalingGroup [Text]
asgLoadBalancerNames =
    lens _asgLoadBalancerNames (\s a -> s { _asgLoadBalancerNames = a })
        . _List
asgMaxSize :: Lens' AutoScalingGroup Int
asgMaxSize = lens _asgMaxSize (\s a -> s { _asgMaxSize = a })
asgMinSize :: Lens' AutoScalingGroup Int
asgMinSize = lens _asgMinSize (\s a -> s { _asgMinSize = a })
asgPlacementGroup :: Lens' AutoScalingGroup (Maybe Text)
asgPlacementGroup =
    lens _asgPlacementGroup (\s a -> s { _asgPlacementGroup = a })
asgStatus :: Lens' AutoScalingGroup (Maybe Text)
asgStatus = lens _asgStatus (\s a -> s { _asgStatus = a })
asgSuspendedProcesses :: Lens' AutoScalingGroup [SuspendedProcess]
asgSuspendedProcesses =
    lens _asgSuspendedProcesses (\s a -> s { _asgSuspendedProcesses = a })
        . _List
asgTags :: Lens' AutoScalingGroup [TagDescription]
asgTags = lens _asgTags (\s a -> s { _asgTags = a }) . _List
asgTerminationPolicies :: Lens' AutoScalingGroup [Text]
asgTerminationPolicies =
    lens _asgTerminationPolicies (\s a -> s { _asgTerminationPolicies = a })
        . _List
asgVPCZoneIdentifier :: Lens' AutoScalingGroup (Maybe Text)
asgVPCZoneIdentifier =
    lens _asgVPCZoneIdentifier (\s a -> s { _asgVPCZoneIdentifier = a })
instance FromXML AutoScalingGroup where
    parseXML x = AutoScalingGroup
        <$> x .@? "AutoScalingGroupARN"
        <*> x .@  "AutoScalingGroupName"
        <*> x .@  "AvailabilityZones"
        <*> x .@  "CreatedTime"
        <*> x .@  "DefaultCooldown"
        <*> x .@  "DesiredCapacity"
        <*> x .@? "EnabledMetrics" .!@ mempty
        <*> x .@? "HealthCheckGracePeriod"
        <*> x .@  "HealthCheckType"
        <*> x .@? "Instances" .!@ mempty
        <*> x .@  "LaunchConfigurationName"
        <*> x .@? "LoadBalancerNames" .!@ mempty
        <*> x .@  "MaxSize"
        <*> x .@  "MinSize"
        <*> x .@? "PlacementGroup"
        <*> x .@? "Status"
        <*> x .@? "SuspendedProcesses" .!@ mempty
        <*> x .@? "Tags" .!@ mempty
        <*> x .@? "TerminationPolicies" .!@ mempty
        <*> x .@? "VPCZoneIdentifier"
instance ToQuery AutoScalingGroup where
    toQuery AutoScalingGroup{..} = mconcat
        [ "AutoScalingGroupARN"     =? _asgAutoScalingGroupARN
        , "AutoScalingGroupName"    =? _asgAutoScalingGroupName
        , "AvailabilityZones"       =? _asgAvailabilityZones
        , "CreatedTime"             =? _asgCreatedTime
        , "DefaultCooldown"         =? _asgDefaultCooldown
        , "DesiredCapacity"         =? _asgDesiredCapacity
        , "EnabledMetrics"          =? _asgEnabledMetrics
        , "HealthCheckGracePeriod"  =? _asgHealthCheckGracePeriod
        , "HealthCheckType"         =? _asgHealthCheckType
        , "Instances"               =? _asgInstances
        , "LaunchConfigurationName" =? _asgLaunchConfigurationName
        , "LoadBalancerNames"       =? _asgLoadBalancerNames
        , "MaxSize"                 =? _asgMaxSize
        , "MinSize"                 =? _asgMinSize
        , "PlacementGroup"          =? _asgPlacementGroup
        , "Status"                  =? _asgStatus
        , "SuspendedProcesses"      =? _asgSuspendedProcesses
        , "Tags"                    =? _asgTags
        , "TerminationPolicies"     =? _asgTerminationPolicies
        , "VPCZoneIdentifier"       =? _asgVPCZoneIdentifier
        ]
data ScalingPolicy = ScalingPolicy
    { _sp1AdjustmentType       :: Maybe Text
    , _sp1Alarms               :: List "member" Alarm
    , _sp1AutoScalingGroupName :: Maybe Text
    , _sp1Cooldown             :: Maybe Int
    , _sp1MinAdjustmentStep    :: Maybe Int
    , _sp1PolicyARN            :: Maybe Text
    , _sp1PolicyName           :: Maybe Text
    , _sp1ScalingAdjustment    :: Maybe Int
    } deriving (Eq, Show)
scalingPolicy :: ScalingPolicy
scalingPolicy = ScalingPolicy
    { _sp1AutoScalingGroupName = Nothing
    , _sp1PolicyName           = Nothing
    , _sp1ScalingAdjustment    = Nothing
    , _sp1AdjustmentType       = Nothing
    , _sp1Cooldown             = Nothing
    , _sp1PolicyARN            = Nothing
    , _sp1Alarms               = mempty
    , _sp1MinAdjustmentStep    = Nothing
    }
sp1AdjustmentType :: Lens' ScalingPolicy (Maybe Text)
sp1AdjustmentType =
    lens _sp1AdjustmentType (\s a -> s { _sp1AdjustmentType = a })
sp1Alarms :: Lens' ScalingPolicy [Alarm]
sp1Alarms = lens _sp1Alarms (\s a -> s { _sp1Alarms = a }) . _List
sp1AutoScalingGroupName :: Lens' ScalingPolicy (Maybe Text)
sp1AutoScalingGroupName =
    lens _sp1AutoScalingGroupName (\s a -> s { _sp1AutoScalingGroupName = a })
sp1Cooldown :: Lens' ScalingPolicy (Maybe Int)
sp1Cooldown = lens _sp1Cooldown (\s a -> s { _sp1Cooldown = a })
sp1MinAdjustmentStep :: Lens' ScalingPolicy (Maybe Int)
sp1MinAdjustmentStep =
    lens _sp1MinAdjustmentStep (\s a -> s { _sp1MinAdjustmentStep = a })
sp1PolicyARN :: Lens' ScalingPolicy (Maybe Text)
sp1PolicyARN = lens _sp1PolicyARN (\s a -> s { _sp1PolicyARN = a })
sp1PolicyName :: Lens' ScalingPolicy (Maybe Text)
sp1PolicyName = lens _sp1PolicyName (\s a -> s { _sp1PolicyName = a })
sp1ScalingAdjustment :: Lens' ScalingPolicy (Maybe Int)
sp1ScalingAdjustment =
    lens _sp1ScalingAdjustment (\s a -> s { _sp1ScalingAdjustment = a })
instance FromXML ScalingPolicy where
    parseXML x = ScalingPolicy
        <$> x .@? "AdjustmentType"
        <*> x .@? "Alarms" .!@ mempty
        <*> x .@? "AutoScalingGroupName"
        <*> x .@? "Cooldown"
        <*> x .@? "MinAdjustmentStep"
        <*> x .@? "PolicyARN"
        <*> x .@? "PolicyName"
        <*> x .@? "ScalingAdjustment"
instance ToQuery ScalingPolicy where
    toQuery ScalingPolicy{..} = mconcat
        [ "AdjustmentType"       =? _sp1AdjustmentType
        , "Alarms"               =? _sp1Alarms
        , "AutoScalingGroupName" =? _sp1AutoScalingGroupName
        , "Cooldown"             =? _sp1Cooldown
        , "MinAdjustmentStep"    =? _sp1MinAdjustmentStep
        , "PolicyARN"            =? _sp1PolicyARN
        , "PolicyName"           =? _sp1PolicyName
        , "ScalingAdjustment"    =? _sp1ScalingAdjustment
        ]
newtype InstanceMonitoring = InstanceMonitoring
    { _imEnabled :: Maybe Bool
    } deriving (Eq, Ord, Show)
instanceMonitoring :: InstanceMonitoring
instanceMonitoring = InstanceMonitoring
    { _imEnabled = Nothing
    }
imEnabled :: Lens' InstanceMonitoring (Maybe Bool)
imEnabled = lens _imEnabled (\s a -> s { _imEnabled = a })
instance FromXML InstanceMonitoring where
    parseXML x = InstanceMonitoring
        <$> x .@? "Enabled"
instance ToQuery InstanceMonitoring where
    toQuery InstanceMonitoring{..} = mconcat
        [ "Enabled" =? _imEnabled
        ]
data ScheduledUpdateGroupAction = ScheduledUpdateGroupAction
    { _sugaAutoScalingGroupName :: Maybe Text
    , _sugaDesiredCapacity      :: Maybe Int
    , _sugaEndTime              :: Maybe ISO8601
    , _sugaMaxSize              :: Maybe Int
    , _sugaMinSize              :: Maybe Int
    , _sugaRecurrence           :: Maybe Text
    , _sugaScheduledActionARN   :: Maybe Text
    , _sugaScheduledActionName  :: Maybe Text
    , _sugaStartTime            :: Maybe ISO8601
    , _sugaTime                 :: Maybe ISO8601
    } deriving (Eq, Ord, Show)
scheduledUpdateGroupAction :: ScheduledUpdateGroupAction
scheduledUpdateGroupAction = ScheduledUpdateGroupAction
    { _sugaAutoScalingGroupName = Nothing
    , _sugaScheduledActionName  = Nothing
    , _sugaScheduledActionARN   = Nothing
    , _sugaTime                 = Nothing
    , _sugaStartTime            = Nothing
    , _sugaEndTime              = Nothing
    , _sugaRecurrence           = Nothing
    , _sugaMinSize              = Nothing
    , _sugaMaxSize              = Nothing
    , _sugaDesiredCapacity      = Nothing
    }
sugaAutoScalingGroupName :: Lens' ScheduledUpdateGroupAction (Maybe Text)
sugaAutoScalingGroupName =
    lens _sugaAutoScalingGroupName
        (\s a -> s { _sugaAutoScalingGroupName = a })
sugaDesiredCapacity :: Lens' ScheduledUpdateGroupAction (Maybe Int)
sugaDesiredCapacity =
    lens _sugaDesiredCapacity (\s a -> s { _sugaDesiredCapacity = a })
sugaEndTime :: Lens' ScheduledUpdateGroupAction (Maybe UTCTime)
sugaEndTime = lens _sugaEndTime (\s a -> s { _sugaEndTime = a }) . mapping _Time
sugaMaxSize :: Lens' ScheduledUpdateGroupAction (Maybe Int)
sugaMaxSize = lens _sugaMaxSize (\s a -> s { _sugaMaxSize = a })
sugaMinSize :: Lens' ScheduledUpdateGroupAction (Maybe Int)
sugaMinSize = lens _sugaMinSize (\s a -> s { _sugaMinSize = a })
sugaRecurrence :: Lens' ScheduledUpdateGroupAction (Maybe Text)
sugaRecurrence = lens _sugaRecurrence (\s a -> s { _sugaRecurrence = a })
sugaScheduledActionARN :: Lens' ScheduledUpdateGroupAction (Maybe Text)
sugaScheduledActionARN =
    lens _sugaScheduledActionARN (\s a -> s { _sugaScheduledActionARN = a })
sugaScheduledActionName :: Lens' ScheduledUpdateGroupAction (Maybe Text)
sugaScheduledActionName =
    lens _sugaScheduledActionName (\s a -> s { _sugaScheduledActionName = a })
sugaStartTime :: Lens' ScheduledUpdateGroupAction (Maybe UTCTime)
sugaStartTime = lens _sugaStartTime (\s a -> s { _sugaStartTime = a }) . mapping _Time
sugaTime :: Lens' ScheduledUpdateGroupAction (Maybe UTCTime)
sugaTime = lens _sugaTime (\s a -> s { _sugaTime = a }) . mapping _Time
instance FromXML ScheduledUpdateGroupAction where
    parseXML x = ScheduledUpdateGroupAction
        <$> x .@? "AutoScalingGroupName"
        <*> x .@? "DesiredCapacity"
        <*> x .@? "EndTime"
        <*> x .@? "MaxSize"
        <*> x .@? "MinSize"
        <*> x .@? "Recurrence"
        <*> x .@? "ScheduledActionARN"
        <*> x .@? "ScheduledActionName"
        <*> x .@? "StartTime"
        <*> x .@? "Time"
instance ToQuery ScheduledUpdateGroupAction where
    toQuery ScheduledUpdateGroupAction{..} = mconcat
        [ "AutoScalingGroupName" =? _sugaAutoScalingGroupName
        , "DesiredCapacity"      =? _sugaDesiredCapacity
        , "EndTime"              =? _sugaEndTime
        , "MaxSize"              =? _sugaMaxSize
        , "MinSize"              =? _sugaMinSize
        , "Recurrence"           =? _sugaRecurrence
        , "ScheduledActionARN"   =? _sugaScheduledActionARN
        , "ScheduledActionName"  =? _sugaScheduledActionName
        , "StartTime"            =? _sugaStartTime
        , "Time"                 =? _sugaTime
        ]
data ScalingProcessQuery = ScalingProcessQuery
    { _spqAutoScalingGroupName :: Text
    , _spqScalingProcesses     :: List "member" Text
    } deriving (Eq, Ord, Show)
scalingProcessQuery :: Text 
                    -> ScalingProcessQuery
scalingProcessQuery p1 = ScalingProcessQuery
    { _spqAutoScalingGroupName = p1
    , _spqScalingProcesses     = mempty
    }
spqAutoScalingGroupName :: Lens' ScalingProcessQuery Text
spqAutoScalingGroupName =
    lens _spqAutoScalingGroupName (\s a -> s { _spqAutoScalingGroupName = a })
spqScalingProcesses :: Lens' ScalingProcessQuery [Text]
spqScalingProcesses =
    lens _spqScalingProcesses (\s a -> s { _spqScalingProcesses = a })
        . _List
instance FromXML ScalingProcessQuery where
    parseXML x = ScalingProcessQuery
        <$> x .@  "AutoScalingGroupName"
        <*> x .@? "ScalingProcesses" .!@ mempty
instance ToQuery ScalingProcessQuery where
    toQuery ScalingProcessQuery{..} = mconcat
        [ "AutoScalingGroupName" =? _spqAutoScalingGroupName
        , "ScalingProcesses"     =? _spqScalingProcesses
        ]
data Ebs = Ebs
    { _ebsDeleteOnTermination :: Maybe Bool
    , _ebsIops                :: Maybe Nat
    , _ebsSnapshotId          :: Maybe Text
    , _ebsVolumeSize          :: Maybe Nat
    , _ebsVolumeType          :: Maybe Text
    } deriving (Eq, Ord, Show)
ebs :: Ebs
ebs = Ebs
    { _ebsSnapshotId          = Nothing
    , _ebsVolumeSize          = Nothing
    , _ebsVolumeType          = Nothing
    , _ebsDeleteOnTermination = Nothing
    , _ebsIops                = Nothing
    }
ebsDeleteOnTermination :: Lens' Ebs (Maybe Bool)
ebsDeleteOnTermination =
    lens _ebsDeleteOnTermination (\s a -> s { _ebsDeleteOnTermination = a })
ebsIops :: Lens' Ebs (Maybe Natural)
ebsIops = lens _ebsIops (\s a -> s { _ebsIops = a }) . mapping _Nat
ebsSnapshotId :: Lens' Ebs (Maybe Text)
ebsSnapshotId = lens _ebsSnapshotId (\s a -> s { _ebsSnapshotId = a })
ebsVolumeSize :: Lens' Ebs (Maybe Natural)
ebsVolumeSize = lens _ebsVolumeSize (\s a -> s { _ebsVolumeSize = a }) . mapping _Nat
ebsVolumeType :: Lens' Ebs (Maybe Text)
ebsVolumeType = lens _ebsVolumeType (\s a -> s { _ebsVolumeType = a })
instance FromXML Ebs where
    parseXML x = Ebs
        <$> x .@? "DeleteOnTermination"
        <*> x .@? "Iops"
        <*> x .@? "SnapshotId"
        <*> x .@? "VolumeSize"
        <*> x .@? "VolumeType"
instance ToQuery Ebs where
    toQuery Ebs{..} = mconcat
        [ "DeleteOnTermination" =? _ebsDeleteOnTermination
        , "Iops"                =? _ebsIops
        , "SnapshotId"          =? _ebsSnapshotId
        , "VolumeSize"          =? _ebsVolumeSize
        , "VolumeType"          =? _ebsVolumeType
        ]
newtype AdjustmentType = AdjustmentType
    { _atAdjustmentType :: Maybe Text
    } deriving (Eq, Ord, Show, Monoid)
adjustmentType :: AdjustmentType
adjustmentType = AdjustmentType
    { _atAdjustmentType = Nothing
    }
atAdjustmentType :: Lens' AdjustmentType (Maybe Text)
atAdjustmentType = lens _atAdjustmentType (\s a -> s { _atAdjustmentType = a })
instance FromXML AdjustmentType where
    parseXML x = AdjustmentType
        <$> x .@? "AdjustmentType"
instance ToQuery AdjustmentType where
    toQuery AdjustmentType{..} = mconcat
        [ "AdjustmentType" =? _atAdjustmentType
        ]
newtype MetricCollectionType = MetricCollectionType
    { _mctMetric :: Maybe Text
    } deriving (Eq, Ord, Show, Monoid)
metricCollectionType :: MetricCollectionType
metricCollectionType = MetricCollectionType
    { _mctMetric = Nothing
    }
mctMetric :: Lens' MetricCollectionType (Maybe Text)
mctMetric = lens _mctMetric (\s a -> s { _mctMetric = a })
instance FromXML MetricCollectionType where
    parseXML x = MetricCollectionType
        <$> x .@? "Metric"
instance ToQuery MetricCollectionType where
    toQuery MetricCollectionType{..} = mconcat
        [ "Metric" =? _mctMetric
        ]
data LifecycleHook = LifecycleHook
    { _lhAutoScalingGroupName  :: Maybe Text
    , _lhDefaultResult         :: Maybe Text
    , _lhGlobalTimeout         :: Maybe Int
    , _lhHeartbeatTimeout      :: Maybe Int
    , _lhLifecycleHookName     :: Maybe Text
    , _lhLifecycleTransition   :: Maybe Text
    , _lhNotificationMetadata  :: Maybe Text
    , _lhNotificationTargetARN :: Maybe Text
    , _lhRoleARN               :: Maybe Text
    } deriving (Eq, Ord, Show)
lifecycleHook :: LifecycleHook
lifecycleHook = LifecycleHook
    { _lhLifecycleHookName     = Nothing
    , _lhAutoScalingGroupName  = Nothing
    , _lhLifecycleTransition   = Nothing
    , _lhNotificationTargetARN = Nothing
    , _lhRoleARN               = Nothing
    , _lhNotificationMetadata  = Nothing
    , _lhHeartbeatTimeout      = Nothing
    , _lhGlobalTimeout         = Nothing
    , _lhDefaultResult         = Nothing
    }
lhAutoScalingGroupName :: Lens' LifecycleHook (Maybe Text)
lhAutoScalingGroupName =
    lens _lhAutoScalingGroupName (\s a -> s { _lhAutoScalingGroupName = a })
lhDefaultResult :: Lens' LifecycleHook (Maybe Text)
lhDefaultResult = lens _lhDefaultResult (\s a -> s { _lhDefaultResult = a })
lhGlobalTimeout :: Lens' LifecycleHook (Maybe Int)
lhGlobalTimeout = lens _lhGlobalTimeout (\s a -> s { _lhGlobalTimeout = a })
lhHeartbeatTimeout :: Lens' LifecycleHook (Maybe Int)
lhHeartbeatTimeout =
    lens _lhHeartbeatTimeout (\s a -> s { _lhHeartbeatTimeout = a })
lhLifecycleHookName :: Lens' LifecycleHook (Maybe Text)
lhLifecycleHookName =
    lens _lhLifecycleHookName (\s a -> s { _lhLifecycleHookName = a })
lhLifecycleTransition :: Lens' LifecycleHook (Maybe Text)
lhLifecycleTransition =
    lens _lhLifecycleTransition (\s a -> s { _lhLifecycleTransition = a })
lhNotificationMetadata :: Lens' LifecycleHook (Maybe Text)
lhNotificationMetadata =
    lens _lhNotificationMetadata (\s a -> s { _lhNotificationMetadata = a })
lhNotificationTargetARN :: Lens' LifecycleHook (Maybe Text)
lhNotificationTargetARN =
    lens _lhNotificationTargetARN (\s a -> s { _lhNotificationTargetARN = a })
lhRoleARN :: Lens' LifecycleHook (Maybe Text)
lhRoleARN = lens _lhRoleARN (\s a -> s { _lhRoleARN = a })
instance FromXML LifecycleHook where
    parseXML x = LifecycleHook
        <$> x .@? "AutoScalingGroupName"
        <*> x .@? "DefaultResult"
        <*> x .@? "GlobalTimeout"
        <*> x .@? "HeartbeatTimeout"
        <*> x .@? "LifecycleHookName"
        <*> x .@? "LifecycleTransition"
        <*> x .@? "NotificationMetadata"
        <*> x .@? "NotificationTargetARN"
        <*> x .@? "RoleARN"
instance ToQuery LifecycleHook where
    toQuery LifecycleHook{..} = mconcat
        [ "AutoScalingGroupName"  =? _lhAutoScalingGroupName
        , "DefaultResult"         =? _lhDefaultResult
        , "GlobalTimeout"         =? _lhGlobalTimeout
        , "HeartbeatTimeout"      =? _lhHeartbeatTimeout
        , "LifecycleHookName"     =? _lhLifecycleHookName
        , "LifecycleTransition"   =? _lhLifecycleTransition
        , "NotificationMetadata"  =? _lhNotificationMetadata
        , "NotificationTargetARN" =? _lhNotificationTargetARN
        , "RoleARN"               =? _lhRoleARN
        ]
data Activity = Activity
    { _aActivityId           :: Text
    , _aAutoScalingGroupName :: Text
    , _aCause                :: Text
    , _aDescription          :: Maybe Text
    , _aDetails              :: Maybe Text
    , _aEndTime              :: Maybe ISO8601
    , _aProgress             :: Maybe Int
    , _aStartTime            :: ISO8601
    , _aStatusCode           :: ScalingActivityStatusCode
    , _aStatusMessage        :: Maybe Text
    } deriving (Eq, Show)
activity :: Text 
         -> Text 
         -> Text 
         -> UTCTime 
         -> ScalingActivityStatusCode 
         -> Activity
activity p1 p2 p3 p4 p5 = Activity
    { _aActivityId           = p1
    , _aAutoScalingGroupName = p2
    , _aCause                = p3
    , _aStartTime            = withIso _Time (const id) p4
    , _aStatusCode           = p5
    , _aDescription          = Nothing
    , _aEndTime              = Nothing
    , _aStatusMessage        = Nothing
    , _aProgress             = Nothing
    , _aDetails              = Nothing
    }
aActivityId :: Lens' Activity Text
aActivityId = lens _aActivityId (\s a -> s { _aActivityId = a })
aAutoScalingGroupName :: Lens' Activity Text
aAutoScalingGroupName =
    lens _aAutoScalingGroupName (\s a -> s { _aAutoScalingGroupName = a })
aCause :: Lens' Activity Text
aCause = lens _aCause (\s a -> s { _aCause = a })
aDescription :: Lens' Activity (Maybe Text)
aDescription = lens _aDescription (\s a -> s { _aDescription = a })
aDetails :: Lens' Activity (Maybe Text)
aDetails = lens _aDetails (\s a -> s { _aDetails = a })
aEndTime :: Lens' Activity (Maybe UTCTime)
aEndTime = lens _aEndTime (\s a -> s { _aEndTime = a }) . mapping _Time
aProgress :: Lens' Activity (Maybe Int)
aProgress = lens _aProgress (\s a -> s { _aProgress = a })
aStartTime :: Lens' Activity UTCTime
aStartTime = lens _aStartTime (\s a -> s { _aStartTime = a }) . _Time
aStatusCode :: Lens' Activity ScalingActivityStatusCode
aStatusCode = lens _aStatusCode (\s a -> s { _aStatusCode = a })
aStatusMessage :: Lens' Activity (Maybe Text)
aStatusMessage = lens _aStatusMessage (\s a -> s { _aStatusMessage = a })
instance FromXML Activity where
    parseXML x = Activity
        <$> x .@  "ActivityId"
        <*> x .@  "AutoScalingGroupName"
        <*> x .@  "Cause"
        <*> x .@? "Description"
        <*> x .@? "Details"
        <*> x .@? "EndTime"
        <*> x .@? "Progress"
        <*> x .@  "StartTime"
        <*> x .@  "StatusCode"
        <*> x .@? "StatusMessage"
instance ToQuery Activity where
    toQuery Activity{..} = mconcat
        [ "ActivityId"           =? _aActivityId
        , "AutoScalingGroupName" =? _aAutoScalingGroupName
        , "Cause"                =? _aCause
        , "Description"          =? _aDescription
        , "Details"              =? _aDetails
        , "EndTime"              =? _aEndTime
        , "Progress"             =? _aProgress
        , "StartTime"            =? _aStartTime
        , "StatusCode"           =? _aStatusCode
        , "StatusMessage"        =? _aStatusMessage
        ]
data SuspendedProcess = SuspendedProcess
    { _spProcessName      :: Maybe Text
    , _spSuspensionReason :: Maybe Text
    } deriving (Eq, Ord, Show)
suspendedProcess :: SuspendedProcess
suspendedProcess = SuspendedProcess
    { _spProcessName      = Nothing
    , _spSuspensionReason = Nothing
    }
spProcessName :: Lens' SuspendedProcess (Maybe Text)
spProcessName = lens _spProcessName (\s a -> s { _spProcessName = a })
spSuspensionReason :: Lens' SuspendedProcess (Maybe Text)
spSuspensionReason =
    lens _spSuspensionReason (\s a -> s { _spSuspensionReason = a })
instance FromXML SuspendedProcess where
    parseXML x = SuspendedProcess
        <$> x .@? "ProcessName"
        <*> x .@? "SuspensionReason"
instance ToQuery SuspendedProcess where
    toQuery SuspendedProcess{..} = mconcat
        [ "ProcessName"      =? _spProcessName
        , "SuspensionReason" =? _spSuspensionReason
        ]
newtype MetricGranularityType = MetricGranularityType
    { _mgtGranularity :: Maybe Text
    } deriving (Eq, Ord, Show, Monoid)
metricGranularityType :: MetricGranularityType
metricGranularityType = MetricGranularityType
    { _mgtGranularity = Nothing
    }
mgtGranularity :: Lens' MetricGranularityType (Maybe Text)
mgtGranularity = lens _mgtGranularity (\s a -> s { _mgtGranularity = a })
instance FromXML MetricGranularityType where
    parseXML x = MetricGranularityType
        <$> x .@? "Granularity"
instance ToQuery MetricGranularityType where
    toQuery MetricGranularityType{..} = mconcat
        [ "Granularity" =? _mgtGranularity
        ]
data Filter = Filter
    { _fName   :: Text
    , _fValues :: List "member" Text
    } deriving (Eq, Ord, Show)
filter' :: Text 
        -> Filter
filter' p1 = Filter
    { _fName   = p1
    , _fValues = mempty
    }
fName :: Lens' Filter Text
fName = lens _fName (\s a -> s { _fName = a })
fValues :: Lens' Filter [Text]
fValues = lens _fValues (\s a -> s { _fValues = a }) . _List
instance FromXML Filter where
    parseXML x = Filter
        <$> x .@  "Name"
        <*> x .@? "Values" .!@ mempty
instance ToQuery Filter where
    toQuery Filter{..} = mconcat
        [ "Name"   =? _fName
        , "Values" =? _fValues
        ]
newtype ProcessType = ProcessType
    { _ptProcessName :: Text
    } deriving (Eq, Ord, Show, Monoid, IsString)
processType :: Text 
            -> ProcessType
processType p1 = ProcessType
    { _ptProcessName = p1
    }
ptProcessName :: Lens' ProcessType Text
ptProcessName = lens _ptProcessName (\s a -> s { _ptProcessName = a })
instance FromXML ProcessType where
    parseXML x = ProcessType
        <$> x .@  "ProcessName"
instance ToQuery ProcessType where
    toQuery ProcessType{..} = mconcat
        [ "ProcessName" =? _ptProcessName
        ]
data Alarm = Alarm
    { _aAlarmARN  :: Maybe Text
    , _aAlarmName :: Maybe Text
    } deriving (Eq, Ord, Show)
alarm :: Alarm
alarm = Alarm
    { _aAlarmName = Nothing
    , _aAlarmARN  = Nothing
    }
aAlarmARN :: Lens' Alarm (Maybe Text)
aAlarmARN = lens _aAlarmARN (\s a -> s { _aAlarmARN = a })
aAlarmName :: Lens' Alarm (Maybe Text)
aAlarmName = lens _aAlarmName (\s a -> s { _aAlarmName = a })
instance FromXML Alarm where
    parseXML x = Alarm
        <$> x .@? "AlarmARN"
        <*> x .@? "AlarmName"
instance ToQuery Alarm where
    toQuery Alarm{..} = mconcat
        [ "AlarmARN"  =? _aAlarmARN
        , "AlarmName" =? _aAlarmName
        ]
data EnabledMetric = EnabledMetric
    { _emGranularity :: Maybe Text
    , _emMetric      :: Maybe Text
    } deriving (Eq, Ord, Show)
enabledMetric :: EnabledMetric
enabledMetric = EnabledMetric
    { _emMetric      = Nothing
    , _emGranularity = Nothing
    }
emGranularity :: Lens' EnabledMetric (Maybe Text)
emGranularity = lens _emGranularity (\s a -> s { _emGranularity = a })
emMetric :: Lens' EnabledMetric (Maybe Text)
emMetric = lens _emMetric (\s a -> s { _emMetric = a })
instance FromXML EnabledMetric where
    parseXML x = EnabledMetric
        <$> x .@? "Granularity"
        <*> x .@? "Metric"
instance ToQuery EnabledMetric where
    toQuery EnabledMetric{..} = mconcat
        [ "Granularity" =? _emGranularity
        , "Metric"      =? _emMetric
        ]
data Instance = Instance
    { _iAvailabilityZone        :: Text
    , _iHealthStatus            :: Text
    , _iInstanceId              :: Text
    , _iLaunchConfigurationName :: Text
    , _iLifecycleState          :: LifecycleState
    } deriving (Eq, Show)
instance' :: Text 
          -> Text 
          -> LifecycleState 
          -> Text 
          -> Text 
          -> Instance
instance' p1 p2 p3 p4 p5 = Instance
    { _iInstanceId              = p1
    , _iAvailabilityZone        = p2
    , _iLifecycleState          = p3
    , _iHealthStatus            = p4
    , _iLaunchConfigurationName = p5
    }
iAvailabilityZone :: Lens' Instance Text
iAvailabilityZone =
    lens _iAvailabilityZone (\s a -> s { _iAvailabilityZone = a })
iHealthStatus :: Lens' Instance Text
iHealthStatus = lens _iHealthStatus (\s a -> s { _iHealthStatus = a })
iInstanceId :: Lens' Instance Text
iInstanceId = lens _iInstanceId (\s a -> s { _iInstanceId = a })
iLaunchConfigurationName :: Lens' Instance Text
iLaunchConfigurationName =
    lens _iLaunchConfigurationName
        (\s a -> s { _iLaunchConfigurationName = a })
iLifecycleState :: Lens' Instance LifecycleState
iLifecycleState = lens _iLifecycleState (\s a -> s { _iLifecycleState = a })
instance FromXML Instance where
    parseXML x = Instance
        <$> x .@  "AvailabilityZone"
        <*> x .@  "HealthStatus"
        <*> x .@  "InstanceId"
        <*> x .@  "LaunchConfigurationName"
        <*> x .@  "LifecycleState"
instance ToQuery Instance where
    toQuery Instance{..} = mconcat
        [ "AvailabilityZone"        =? _iAvailabilityZone
        , "HealthStatus"            =? _iHealthStatus
        , "InstanceId"              =? _iInstanceId
        , "LaunchConfigurationName" =? _iLaunchConfigurationName
        , "LifecycleState"          =? _iLifecycleState
        ]
data LifecycleState
    = Detached           
    | Detaching          
    | EnteringStandby    
    | InService          
    | Pending            
    | PendingProceed     
    | PendingWait        
    | Quarantined        
    | Standby            
    | Terminated         
    | Terminating        
    | TerminatingProceed 
    | TerminatingWait    
      deriving (Eq, Ord, Show, Generic, Enum)
instance Hashable LifecycleState
instance FromText LifecycleState where
    parser = takeText >>= \case
        "Detached"            -> pure Detached
        "Detaching"           -> pure Detaching
        "EnteringStandby"     -> pure EnteringStandby
        "InService"           -> pure InService
        "Pending"             -> pure Pending
        "Pending:Proceed"     -> pure PendingProceed
        "Pending:Wait"        -> pure PendingWait
        "Quarantined"         -> pure Quarantined
        "Standby"             -> pure Standby
        "Terminated"          -> pure Terminated
        "Terminating"         -> pure Terminating
        "Terminating:Proceed" -> pure TerminatingProceed
        "Terminating:Wait"    -> pure TerminatingWait
        e                     -> fail $
            "Failure parsing LifecycleState from " ++ show e
instance ToText LifecycleState where
    toText = \case
        Detached           -> "Detached"
        Detaching          -> "Detaching"
        EnteringStandby    -> "EnteringStandby"
        InService          -> "InService"
        Pending            -> "Pending"
        PendingProceed     -> "Pending:Proceed"
        PendingWait        -> "Pending:Wait"
        Quarantined        -> "Quarantined"
        Standby            -> "Standby"
        Terminated         -> "Terminated"
        Terminating        -> "Terminating"
        TerminatingProceed -> "Terminating:Proceed"
        TerminatingWait    -> "Terminating:Wait"
instance ToByteString LifecycleState
instance ToHeader     LifecycleState
instance ToQuery      LifecycleState
instance FromXML LifecycleState where
    parseXML = parseXMLText "LifecycleState"
data AutoScalingInstanceDetails = AutoScalingInstanceDetails
    { _asidAutoScalingGroupName    :: Text
    , _asidAvailabilityZone        :: Text
    , _asidHealthStatus            :: Text
    , _asidInstanceId              :: Text
    , _asidLaunchConfigurationName :: Text
    , _asidLifecycleState          :: Text
    } deriving (Eq, Ord, Show)
autoScalingInstanceDetails :: Text 
                           -> Text 
                           -> Text 
                           -> Text 
                           -> Text 
                           -> Text 
                           -> AutoScalingInstanceDetails
autoScalingInstanceDetails p1 p2 p3 p4 p5 p6 = AutoScalingInstanceDetails
    { _asidInstanceId              = p1
    , _asidAutoScalingGroupName    = p2
    , _asidAvailabilityZone        = p3
    , _asidLifecycleState          = p4
    , _asidHealthStatus            = p5
    , _asidLaunchConfigurationName = p6
    }
asidAutoScalingGroupName :: Lens' AutoScalingInstanceDetails Text
asidAutoScalingGroupName =
    lens _asidAutoScalingGroupName
        (\s a -> s { _asidAutoScalingGroupName = a })
asidAvailabilityZone :: Lens' AutoScalingInstanceDetails Text
asidAvailabilityZone =
    lens _asidAvailabilityZone (\s a -> s { _asidAvailabilityZone = a })
asidHealthStatus :: Lens' AutoScalingInstanceDetails Text
asidHealthStatus = lens _asidHealthStatus (\s a -> s { _asidHealthStatus = a })
asidInstanceId :: Lens' AutoScalingInstanceDetails Text
asidInstanceId = lens _asidInstanceId (\s a -> s { _asidInstanceId = a })
asidLaunchConfigurationName :: Lens' AutoScalingInstanceDetails Text
asidLaunchConfigurationName =
    lens _asidLaunchConfigurationName
        (\s a -> s { _asidLaunchConfigurationName = a })
asidLifecycleState :: Lens' AutoScalingInstanceDetails Text
asidLifecycleState =
    lens _asidLifecycleState (\s a -> s { _asidLifecycleState = a })
instance FromXML AutoScalingInstanceDetails where
    parseXML x = AutoScalingInstanceDetails
        <$> x .@  "AutoScalingGroupName"
        <*> x .@  "AvailabilityZone"
        <*> x .@  "HealthStatus"
        <*> x .@  "InstanceId"
        <*> x .@  "LaunchConfigurationName"
        <*> x .@  "LifecycleState"
instance ToQuery AutoScalingInstanceDetails where
    toQuery AutoScalingInstanceDetails{..} = mconcat
        [ "AutoScalingGroupName"    =? _asidAutoScalingGroupName
        , "AvailabilityZone"        =? _asidAvailabilityZone
        , "HealthStatus"            =? _asidHealthStatus
        , "InstanceId"              =? _asidInstanceId
        , "LaunchConfigurationName" =? _asidLaunchConfigurationName
        , "LifecycleState"          =? _asidLifecycleState
        ]
data ScalingActivityStatusCode
    = Cancelled                       
    | Failed                          
    | InProgress                      
    | MidLifecycleAction              
    | PreInService                    
    | Successful                      
    | WaitingForELBConnectionDraining 
    | WaitingForInstanceId            
    | WaitingForSpotInstanceId        
    | WaitingForSpotInstanceRequestId 
      deriving (Eq, Ord, Show, Generic, Enum)
instance Hashable ScalingActivityStatusCode
instance FromText ScalingActivityStatusCode where
    parser = takeText >>= \case
        "Cancelled"                       -> pure Cancelled
        "Failed"                          -> pure Failed
        "InProgress"                      -> pure InProgress
        "MidLifecycleAction"              -> pure MidLifecycleAction
        "PreInService"                    -> pure PreInService
        "Successful"                      -> pure Successful
        "WaitingForELBConnectionDraining" -> pure WaitingForELBConnectionDraining
        "WaitingForInstanceId"            -> pure WaitingForInstanceId
        "WaitingForSpotInstanceId"        -> pure WaitingForSpotInstanceId
        "WaitingForSpotInstanceRequestId" -> pure WaitingForSpotInstanceRequestId
        e                                 -> fail $
            "Failure parsing ScalingActivityStatusCode from " ++ show e
instance ToText ScalingActivityStatusCode where
    toText = \case
        Cancelled                       -> "Cancelled"
        Failed                          -> "Failed"
        InProgress                      -> "InProgress"
        MidLifecycleAction              -> "MidLifecycleAction"
        PreInService                    -> "PreInService"
        Successful                      -> "Successful"
        WaitingForELBConnectionDraining -> "WaitingForELBConnectionDraining"
        WaitingForInstanceId            -> "WaitingForInstanceId"
        WaitingForSpotInstanceId        -> "WaitingForSpotInstanceId"
        WaitingForSpotInstanceRequestId -> "WaitingForSpotInstanceRequestId"
instance ToByteString ScalingActivityStatusCode
instance ToHeader     ScalingActivityStatusCode
instance ToQuery      ScalingActivityStatusCode
instance FromXML ScalingActivityStatusCode where
    parseXML = parseXMLText "ScalingActivityStatusCode"