summaryrefslogtreecommitdiff
path: root/designate/objects/adapters/api_v2/zone_master.py
diff options
context:
space:
mode:
Diffstat (limited to 'designate/objects/adapters/api_v2/zone_master.py')
-rw-r--r--designate/objects/adapters/api_v2/zone_master.py41
1 files changed, 17 insertions, 24 deletions
diff --git a/designate/objects/adapters/api_v2/zone_master.py b/designate/objects/adapters/api_v2/zone_master.py
index 838ec81e..4e671efd 100644
--- a/designate/objects/adapters/api_v2/zone_master.py
+++ b/designate/objects/adapters/api_v2/zone_master.py
@@ -18,9 +18,7 @@ from designate import utils
class ZoneMasterAPIv2Adapter(base.APIv2Adapter):
-
ADAPTER_OBJECT = objects.ZoneMaster
-
MODIFICATIONS = {
'fields': {
'value': {
@@ -35,22 +33,20 @@ class ZoneMasterAPIv2Adapter(base.APIv2Adapter):
}
@classmethod
- def _render_object(cls, object, *arg, **kwargs):
- if object.port == 53:
- return object.host
+ def render_object(cls, obj, *arg, **kwargs):
+ if obj.port == 53:
+ return obj.host
else:
- return "%(host)s:%(port)d" % object.to_dict()
+ return "%(host)s:%(port)d" % obj.to_dict()
@classmethod
- def _parse_object(cls, value, object, *args, **kwargs):
- object.host, object.port = utils.split_host_port(value)
- return object
+ def parse_object(cls, value, obj, *args, **kwargs):
+ obj.host, obj.port = utils.split_host_port(value)
+ return obj
class ZoneMasterListAPIv2Adapter(base.APIv2Adapter):
-
ADAPTER_OBJECT = objects.ZoneMasterList
-
MODIFICATIONS = {
'options': {
'links': False,
@@ -60,31 +56,28 @@ class ZoneMasterListAPIv2Adapter(base.APIv2Adapter):
}
@classmethod
- def _render_list(cls, list_object, *args, **kwargs):
-
+ def render_list(cls, list_objects, *args, **kwargs):
r_list = []
-
- for object in list_object:
- r_list.append(cls.get_object_adapter(
- cls.ADAPTER_FORMAT,
- object).render(cls.ADAPTER_FORMAT, object, *args, **kwargs))
-
+ for obj in list_objects:
+ adapter = cls.get_object_adapter(obj)
+ r_list.append(
+ adapter.render(cls.ADAPTER_FORMAT, obj, *args, **kwargs)
+ )
return r_list
@classmethod
- def _parse_list(cls, values, output_object, *args, **kwargs):
-
+ def parse_list(cls, values, output_object, *args, **kwargs):
for value in values:
# Add the object to the list
output_object.append(
# Get the right Adapter
cls.get_object_adapter(
- cls.ADAPTER_FORMAT,
# This gets the internal type of the list, and parses it
# We need to do `get_object_adapter` as we need a new
# instance of the Adapter
output_object.LIST_ITEM_TYPE()).parse(
- value, output_object.LIST_ITEM_TYPE()))
+ value, output_object.LIST_ITEM_TYPE()
+ )
+ )
- # Return the filled list
return output_object