boto-route53
boto-route53 copied to clipboard
added convenience functions to Route53Connection (add_record, del_record)
I added add_record and del_record to Route53Connection to make the interface cleaner, and more approachable for client applications leveraging boto route53.
commit a7c175df7a468e5e69a01015012e4e88d8fa4d64
Author: Alon Swartz <[email protected]>
Date: Tue May 3 09:56:11 2011 +0300
added convenience functions to Route53Connection (add_record, del_record)
diff --git a/boto2/route53/connection.py b/boto2/route53/connection.py
index 7f0ba2d..f274aba 100644
--- a/boto2/route53/connection.py
+++ b/boto2/route53/connection.py
@@ -11,7 +11,7 @@ from boto2.resultset import ResultSet
from change_info import ChangeInfo
from hosted_zone import HostedZone
-from record import Record
+from record import Record, RecordSet
class AWSRestConnection(AWSAuthConnection):
ResponseError = BotoServerError
@@ -240,3 +240,59 @@ class Route53Connection(AWSRestConnection):
:return: The ChangeInfo object for the ID requested.
"""
return self.get_object(['change', change_id], ChangeInfo)
+
+ def add_record(self, hosted_zone_id, name, type, values, ttl, comment=""):
+ """
+ Add record to hosted_zone. Returns an instance of ChangeInfo for checki
+ on the status of the operation.
+
+ :type hosted_zone_id: str
+ :param hosted_zone_id: The unique identifier for the Hosted Zone
+
+ :type name: str
+ :param name: The name of the resource record to create
+
+ :type type: str
+ :param type: The type of resource record to create
+
+ :type values: list
+ :param values: List of values for resource record
+
+ :type ttl: int
+ :param ttl: TTL for the record
+
+ :type comment: str
+ :param comment: Optional comment to include with resource record creati
+ """
+ recordset = RecordSet(self, hosted_zone_id, comment)
+ record = recordset.add_change("CREATE", name, type, ttl)
+ for value in values:
+ record.add_value(value)
+ return recordset.commit()
+
+ def del_record(self, hosted_zone_id, name, type, values, ttl):
+ """
+ Delete record of hosted_zone. Returns an instance of ChangeInfo for che
+ on the status of the operation.
+
+ :type hosted_zone_id: str
+ :param hosted_zone_id: The unique identifier for the Hosted Zone
+
+ :type name: str
+ :param name: The name of the resource record to delete
+
+ :type type: str
+ :param type: The type of resource record to delete
+
+ :type values: list
+ :param values: List of values for resource record
+
+ :type ttl: int
+ :param ttl: TTL of the record
+ """
+ recordset = RecordSet(self, hosted_zone_id)
+ record = recordset.add_change("DELETE", name, type, ttl)
+ for value in values:
+ record.add_value(value)
+ return recordset.commit()
+