Skip to content
Browse files

Added delete_hosted_zone_by_id.

  • Loading branch information...
1 parent be23ffc commit 04d1b82bee4da097b31d67579b5fcb5b1c1bb553 @gtaylor committed
View
20 route53/connection.py
@@ -150,4 +150,24 @@ def get_hosted_zone_by_id(self, id):
return xml_parsers.get_hosted_zone_by_id_parser(
root=root,
connection=self,
+ )
+
+ def delete_hosted_zone_by_id(self, id):
+ """
+ Deletes a hosted zone, by Hosted Zone ID (not name).
+
+ :param str id: The hosted zone's ID (a short hash string).
+ :rtype: dict
+ :returns: A dict with some info regarding the deletion process.
+ """
+
+ root = self._send_request(
+ path='hostedzone/%s' % id,
+ data={},
+ method='DELETE',
+ )
+
+ return xml_parsers.delete_hosted_zone_by_id_parser(
+ root=root,
+ connection=self,
)
View
2 route53/transport.py
@@ -109,7 +109,7 @@ def send_request(self, path, data, method):
elif method == 'POST':
return self._send_post_request(path, data, headers)
elif method == 'DELETE':
- return self._send_post_request(path, headers)
+ return self._send_delete_request(path, headers)
else:
raise Route53Error("Invalid request method: %s" % method)
View
3 route53/xml_parsers/__init__.py
@@ -1,3 +1,4 @@
from .list_hosted_zones import list_hosted_zones_parser
from .created_hosted_zone import created_hosted_zone_parser
-from .get_hosted_zone_by_id import get_hosted_zone_by_id_parser
+from .get_hosted_zone_by_id import get_hosted_zone_by_id_parser
+from .delete_hosted_zone_by_id import delete_hosted_zone_by_id_parser
View
6 route53/xml_parsers/common_hosted_zone.py
@@ -34,6 +34,7 @@ def parse_hosted_zone(zone, connection):
for field in zone:
# Cheesy way to strip off the namespace.
tag_name = field.tag.split('}')[1]
+ field_text = field.text
if tag_name == 'Config':
# Config has the Comment tag beneath it, needing
@@ -41,12 +42,15 @@ def parse_hosted_zone(zone, connection):
comment = field.find('./{*}Comment')
kwargs['comment'] = comment.text if comment is not None else None
continue
+ elif tag_name == 'Id':
+ # This comes back with a path prepended. Yank that sillyness.
+ field_text = field_text.strip('/hostedzone/')
# Map the XML tag name to a kwarg name.
kw_name = HOSTED_ZONE_TAG_TO_KWARG_MAP[tag_name]
# This will be the key/val pair used to instantiate the
# HostedZone instance.
- kwargs[kw_name] = field.text
+ kwargs[kw_name] = field_text
return HostedZone(connection, **kwargs)
View
25 route53/xml_parsers/delete_hosted_zone_by_id.py
@@ -0,0 +1,25 @@
+#noinspection PyUnusedLocal
+def delete_hosted_zone_by_id_parser(root, connection):
+ """
+ Parses the API responses for the
+ :py:meth:`route53.connection.Route53Connection.delete_hosted_zone_by_id` method.
+
+ :param lxml.etree._Element root: The root node of the etree parsed
+ response from the API.
+ :param Route53Connection connection: The connection instance used to
+ query the API.
+ :rtype: dict
+ :returns: Details about the deletion.
+ """
+
+ e_change_info = root.find('./{*}ChangeInfo')
+
+ id = e_change_info.find('./{*}Id').text
+ status = e_change_info.find('./{*}Status').text
+ submitted_at = e_change_info.find('./{*}SubmittedAt').text
+
+ return {
+ 'request_id': id,
+ 'request_status': status,
+ 'request_submitted_at': submitted_at
+ }

0 comments on commit 04d1b82

Please sign in to comment.
Something went wrong with that request. Please try again.