diff --git a/doc/source/user/proxies/dns.rst b/doc/source/user/proxies/dns.rst index 212651df8..cc46163a2 100644 --- a/doc/source/user/proxies/dns.rst +++ b/doc/source/user/proxies/dns.rst @@ -69,6 +69,13 @@ Zone Share Operations :members: create_zone_share, delete_zone_share, get_zone_share, find_zone_share, zone_shares +Limit Operations +^^^^^^^^^^^^^^^^ + +.. autoclass:: openstack.dns.v2._proxy.Proxy + :noindex: + :members: limits + Service Status Operations ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/doc/source/user/resources/dns/index.rst b/doc/source/user/resources/dns/index.rst index c270c67e1..f7cb0e96b 100644 --- a/doc/source/user/resources/dns/index.rst +++ b/doc/source/user/resources/dns/index.rst @@ -11,4 +11,5 @@ DNS Resources v2/zone_share v2/floating_ip v2/recordset + v2/limit v2/service_status diff --git a/doc/source/user/resources/dns/v2/limit.rst b/doc/source/user/resources/dns/v2/limit.rst new file mode 100644 index 000000000..b5af05ea2 --- /dev/null +++ b/doc/source/user/resources/dns/v2/limit.rst @@ -0,0 +1,12 @@ +openstack.dns.v2.limit +====================== + +.. automodule:: openstack.dns.v2.limit + +The Limit Class +--------------- + +The ``Limit`` class inherits from :class:`~openstack.resource.Resource`. + +.. autoclass:: openstack.dns.v2.limit.Limit + :members: diff --git a/openstack/dns/v2/_proxy.py b/openstack/dns/v2/_proxy.py index a5497da62..a3b6a021b 100644 --- a/openstack/dns/v2/_proxy.py +++ b/openstack/dns/v2/_proxy.py @@ -11,6 +11,7 @@ # under the License. from openstack.dns.v2 import floating_ip as _fip +from openstack.dns.v2 import limit as _limit from openstack.dns.v2 import recordset as _rs from openstack.dns.v2 import service_status as _svc_status from openstack.dns.v2 import zone as _zone @@ -24,6 +25,7 @@ from openstack import proxy class Proxy(proxy.Proxy): _resource_registry = { "floating_ip": _fip.FloatingIP, + "limits": _limit.Limit, "recordset": _rs.Recordset, "service_status": _svc_status.ServiceStatus, "zone": _zone.Zone, @@ -658,6 +660,15 @@ class Proxy(proxy.Proxy): zone_id=zone_obj.id, ) + # ======== Limits ======== + def limits(self, **query): + """Retrieve a generator of limits + + :returns: A generator of limits + (:class:`~openstack.dns.v2.limit.Limit`) instances + """ + return self._list(_limit.Limit, **query) + # ======== Service Statuses ======== def service_statuses(self): """Retrieve a generator of service statuses diff --git a/openstack/dns/v2/limit.py b/openstack/dns/v2/limit.py new file mode 100644 index 000000000..c1ac459b6 --- /dev/null +++ b/openstack/dns/v2/limit.py @@ -0,0 +1,44 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from openstack.dns.v2 import _base +from openstack import resource + + +class Limit(_base.Resource): + """DNS Limit Resource""" + + resource_key = 'limit' + base_path = '/limits' + + # capabilities + allow_list = True + + #: Properties + #: The max amount of items allowed per page + max_page_limit = resource.Body('max_page_limit', type=int) + #: The max length of a recordset name + max_recordset_name_length = resource.Body( + 'max_recordset_name_length', type=int + ) + #: The max amount of records contained in a recordset + max_recordset_records = resource.Body('max_recordset_records', type=int) + #: The max length of a zone name + max_zone_name_length = resource.Body('max_zone_name_length', type=int) + #: The max amount of records in a zone + max_zone_records = resource.Body('max_zone_records', type=int) + #: The max amount of recordsets per zone + max_zone_recordsets = resource.Body('max_zone_recordsets', type=int) + #: The max amount of zones for this project + max_zones = resource.Body('max_zones', type=int) + #: The lowest ttl allowed on this system + min_ttl = resource.Body('min_ttl', type=int) diff --git a/openstack/tests/unit/dns/v2/test_limit.py b/openstack/tests/unit/dns/v2/test_limit.py new file mode 100644 index 000000000..e8ace272b --- /dev/null +++ b/openstack/tests/unit/dns/v2/test_limit.py @@ -0,0 +1,35 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from openstack.dns.v2 import limit as _limit +from openstack.tests.unit import base + +IDENTIFIER = 'limit' +EXAMPLE = { + "max_page_limit": 1000, + "max_recordset_name_length": 255, + "max_recordset_records": 20, + "max_zone_name_length": 255, + "max_zone_records": 500, + "max_zone_recordsets": 500, + "max_zones": 10, + "min_ttl": 100, +} + + +class TestLimit(base.TestCase): + def test_basic(self): + sot = _limit.Limit() + self.assertEqual('limit', sot.resource_key) + self.assertEqual(None, sot.resources_key) + self.assertEqual('/limits', sot.base_path) + self.assertTrue(sot.allow_list)