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

from . import AWSHelperFn, AWSObject, AWSProperty, Tags
from .validators import integer, positive_integer, network_port


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 GeoLocation(AWSProperty):
    props = {
        'ContinentCode': (basestring, False),
        'CountryCode': (basestring, False),
        'SubdivisionCode': (basestring, False),
    }


class BaseRecordSet(object):
    props = {
        'AliasTarget': (AliasTarget, False),
        'Comment': (basestring, False),
        'Failover': (basestring, False),
        'GeoLocation': (GeoLocation, False),
        'HealthCheckId': (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
    resource_type = "AWS::Route53::RecordSet"


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


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

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


class HealthCheckConfiguration(AWSProperty):
    props = {
        'FailureThreshold': (positive_integer, False),
        'FullyQualifiedDomainName': (basestring, False),
        'IPAddress': (basestring, False),
        'Port': (network_port, False),
        'RequestInterval': (positive_integer, False),
        'ResourcePath': (basestring, False),
        'SearchString': (basestring, False),
        'Type': (basestring, True),
    }


class HealthCheck(AWSObject):
    resource_type = "AWS::Route53::HealthCheck"

    props = {
        'HealthCheckConfig': (HealthCheckConfiguration, True),
        'HealthCheckTags': (Tags, False),
    }


class HostedZoneConfiguration(AWSProperty):
    props = {
        'Comment': (basestring, False),
    }


class HostedZone(AWSObject):
    resource_type = "AWS::Route53::HostedZone"

    props = {
        'HostedZoneConfig': (HostedZoneConfiguration, False),
        'Name': (basestring, True),
    }

@@ -2696,32 +2696,167 @@
 False),%0A    %7D%0A%0A%0A
+class HostedZoneVPCs(AWSProperty):%0A    props = %7B%0A        'VPCId': (basestring, True),%0A        'VPCRegion': (basestring, True),%0A    %7D%0A%0A%0A
 class HostedZone
@@ -2860,32 +2860,32 @@
 one(AWSObject):%0A
-
     resource_typ
@@ -3001,39 +3001,123 @@
        '
-Name': (basestring, Tru
+HostedZoneTags': (Tags, False),%0A        'Name': (basestring, True),%0A        'VPCs': (%5BHostedZoneVPCs%5D, Fals
 e),%0A    

Add HostedZoneVPCs and HostedZoneTags