# Copyright (c) 2012-2013, Mark Peek <mark@peek.org>
# All rights reserved.
#
# See LICENSE file for full license.

from . import AWSHelperFn, AWSObject, AWSProperty
from .validators import integer


class AliasTarget(AWSHelperFn):
    def __init__(self, hostedzoneid, dnsname, evaluatetargethealth=None):
        self.data = {
            'HostedZoneId': hostedzoneid,
            'DNSName': dnsname,
        }

        if evaluatetargethealth is not None:
            self.data['EvaluateTargetHealth'] = evaluatetargethealth

    def JSONrepr(self):
        return self.data


class BaseRecordSet(object):
    props = {
        'AliasTarget': (AliasTarget, False),
        'Comment': (basestring, False),
        'HostedZoneId': (basestring, False),
        'HostedZoneName': (basestring, False),
        'Name': (basestring, True),
        'Region': (basestring, False),
        'ResourceRecords': (list, False),
        'SetIdentifier': (basestring, False),
        'TTL': (integer, False),
        'Type': (basestring, True),
        'Weight': (integer, False),
    }


class RecordSetType(AWSObject, BaseRecordSet):
    # This is a top-level resource
    type = "AWS::Route53::RecordSet"


class RecordSet(AWSProperty, BaseRecordSet):
    # This is for use in a list with RecordSetGroup (below)
    pass


class RecordSetGroup(AWSObject):
    type = "AWS::Route53::RecordSetGroup"

    props = {
        'HostedZoneId': (basestring, False),
        'HostedZoneName': (basestring, False),
        'RecordSets': (list, False),
        'Comment': (basestring, False),
    }

@@ -190,16 +190,48 @@
  integer
+, positive_integer, network_port
 %0A%0A%0Aclass
@@ -614,106 +614,430 @@
 ass 
-BaseRecordSet(object):%0A    props = %7B%0A        'AliasTarget': (AliasTarget, False),%0A        'Comment
+GeoLocation(AWSProperty):%0A    props = %7B%0A        'ContinentCode': (basestring, False),%0A        'CountryCode': (basestring, False),%0A        'SubdivisionCode': (basestring, False),%0A    %7D%0A%0A%0Aclass BaseRecordSet(object):%0A    props = %7B%0A        'AliasTarget': (AliasTarget, False),%0A        'Comment': (basestring, False),%0A        'Failover': (basestring, False),%0A        'GeoLocation': (GeoLocation, False),%0A        'HealthCheckId
 ': (
@@ -1906,28 +1906,917 @@
  (basestring, False),%0A    %7D%0A
+%0A%0Aclass HealthCheckConfiguration(AWSProperty):%0A    props = %7B%0A        'FailureThreshold': (positive_integer, False),%0A        'FullyQualifiedDomainName': (basestring, False),%0A        'IPAddress': (basestring, False),%0A        'Port': (network_port, False),%0A        'RequestInterval': (positive_integer, False),%0A        'ResourcePath': (basestring, False),%0A        'SearchString': (basestring, False),%0A        'Type': (basestring, True),%0A    %7D%0A%0A%0Aclass HealthCheck(AWSObject):%0A    type = %22AWS::Route53::HealthCheck%22%0A%0A    props = %7B%0A        'HealthCheckConfig': (HealthCheckConfiguration, True),%0A    %7D%0A%0A%0Aclass HostedZoneConfiguration(AWSProperty):%0A    props = %7B%0A        'Comment': (basestring, False),%0A    %7D%0A%0A%0Aclass HostedZone(AWSObject):%0A    type = %22AWS::Route53::HostedZone%22%0A%0A    props = %7B%0A        'HostedZoneConfig': (HostedZoneConfiguration, False),%0A        'Name': (basestring, True),%0A    %7D%0A

Update to 2014-11-06 release