1# Copyright 2015 Hewlett-Packard Development Company, L.P. 2# 3# Author: Endre Karlson <endre.karlson@hp.com> 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); you may 6# not use this file except in compliance with the License. You may obtain 7# a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14# License for the specific language governing permissions and limitations 15# under the License. 16from designateclient.v2.base import V2Controller 17from designateclient.v2 import utils as v2_utils 18 19 20class TLDController(V2Controller): 21 def create(self, name, description=None): 22 data = { 23 'name': name, 24 } 25 26 if description is not None: 27 data["description"] = description 28 29 return self._post('/tlds', data=data) 30 31 def list(self, criterion=None, marker=None, limit=None): 32 url = self.build_url('/tlds', criterion, marker, limit) 33 34 return self._get(url, response_key='tlds') 35 36 def get(self, tld): 37 tld = v2_utils.resolve_by_name(self.list, tld) 38 39 return self._get('/tlds/%s' % tld) 40 41 def update(self, tld, values): 42 tld = v2_utils.resolve_by_name(self.list, tld) 43 44 return self._patch('/tlds/%s' % tld, data=values) 45 46 def delete(self, tld): 47 tld = v2_utils.resolve_by_name(self.list, tld) 48 49 return self._delete('/tlds/%s' % tld) 50