from . import AWSObject, AWSProperty
from .validators import integer


class ScalableTarget(AWSObject):
    resource_type = "AWS::ApplicationAutoScaling::ScalableTarget"

    props = {
        'MaxCapacity': (integer, True),
        'MinCapacity': (integer, True),
        'ResourceId': (basestring, True),
        'RoleARN': (basestring, True),
        'ScalableDimension': (basestring, True),
        'ServiceNamespace': (basestring, True),
    }


class StepAdjustment(AWSProperty):
    props = {
        'MetricIntervalLowerBound': (integer, False),
        'MetricIntervalUpperBound': (integer, False),
        'ScalingAdjustment': (integer, True),
    }


class StepScalingPolicyConfiguration(AWSProperty):
    props = {
        'AdjustmentType': (basestring, False),
        'Cooldown': (integer, False),
        'MetricAggregationType': (basestring, False),
        'MinAdjustmentMagnitude': (integer, False),
        'StepAdjustments': ([StepAdjustment], False),
    }


class ScalingPolicy(AWSObject):
    resource_type = "AWS::ApplicationAutoScaling::ScalingPolicy"

    props = {
        'PolicyName': (basestring, True),
        'PolicyType': (basestring, False),
        'ResourceId': (basestring, False),
        'ScalableDimension': (basestring, False),
        'ServiceNamespace': (basestring, False),
        'ScalingTargetId': (basestring, False),
        'StepScalingPolicyConfiguration': (
            StepScalingPolicyConfiguration,
            False,
        ),
    }

from . import AWSObject, AWSProperty
from .validators import floatingpoint, integer, positive_integer


class ScalableTarget(AWSObject):
    resource_type = "AWS::ApplicationAutoScaling::ScalableTarget"

    props = {
        'MaxCapacity': (integer, True),
        'MinCapacity': (integer, True),
        'ResourceId': (basestring, True),
        'RoleARN': (basestring, True),
        'ScalableDimension': (basestring, True),
        'ServiceNamespace': (basestring, True),
    }


class StepAdjustment(AWSProperty):
    props = {
        'MetricIntervalLowerBound': (integer, False),
        'MetricIntervalUpperBound': (integer, False),
        'ScalingAdjustment': (integer, True),
    }


class StepScalingPolicyConfiguration(AWSProperty):
    props = {
        'AdjustmentType': (basestring, False),
        'Cooldown': (integer, False),
        'MetricAggregationType': (basestring, False),
        'MinAdjustmentMagnitude': (integer, False),
        'StepAdjustments': ([StepAdjustment], False),
    }


class MetricDimension(AWSProperty):
    props = {
        'Name': (basestring, True),
        'Value': (basestring, True),
    }


class CustomizedMetricSpecification(AWSProperty):
    props = {
        'Dimensions': ([MetricDimension], False),
        'MetricName': (basestring, False),
        'Namespace': (basestring, False),
        'Statistic': (basestring, False),
        'Unit': (basestring, True),
    }


class PredefinedMetricSpecification(AWSProperty):
    props = {
        'PredefinedMetricType': (basestring, True),
        'ResourceLabel': (basestring, False),
    }


class TargetTrackingScalingPolicyConfiguration(AWSProperty):
    props = {
        'CustomizedMetricSpecification':
            (CustomizedMetricSpecification, False),
        'PredefinedMetricSpecification':
            (PredefinedMetricSpecification, False),
        'ScaleInCooldown': (positive_integer, False),
        'ScaleOutCooldown': (positive_integer, False),
        'TargetValue': (floatingpoint, True),
    }


class ScalingPolicy(AWSObject):
    resource_type = "AWS::ApplicationAutoScaling::ScalingPolicy"

    props = {
        'PolicyName': (basestring, True),
        'PolicyType': (basestring, False),
        'ResourceId': (basestring, False),
        'ScalableDimension': (basestring, False),
        'ServiceNamespace': (basestring, False),
        'ScalingTargetId': (basestring, False),
        'StepScalingPolicyConfiguration': (
            StepScalingPolicyConfiguration,
            False,
        ),
        'TargetTrackingScalingPolicyConfiguration': (
            TargetTrackingScalingPolicyConfiguration,
            False,
        ),
    }

Add TargetTrackingScalingPolicyConfiguration