003 File Manager
Current Path:
/usr/local/lib/python3.8/site-packages/libcloud/dns/drivers
usr
/
local
/
lib
/
python3.8
/
site-packages
/
libcloud
/
dns
/
drivers
/
📁
..
📄
__init__.py
(0 B)
📁
__pycache__
📄
auroradns.py
(21.66 KB)
📄
buddyns.py
(4.59 KB)
📄
cloudflare.py
(17.12 KB)
📄
digitalocean.py
(10.23 KB)
📄
dnsimple.py
(9.5 KB)
📄
dnspod.py
(11.45 KB)
📄
dummy.py
(7.61 KB)
📄
durabledns.py
(25.59 KB)
📄
gandi.py
(8.97 KB)
📄
gandi_live.py
(17.87 KB)
📄
godaddy.py
(15.61 KB)
📄
google.py
(12.33 KB)
📄
hostvirtual.py
(9.15 KB)
📄
linode.py
(22.49 KB)
📄
liquidweb.py
(12.6 KB)
📄
luadns.py
(9.38 KB)
📄
nfsn.py
(7 KB)
📄
nsone.py
(11.78 KB)
📄
onapp.py
(10.43 KB)
📄
pointdns.py
(27.75 KB)
📄
powerdns.py
(19.19 KB)
📄
rackspace.py
(24.02 KB)
📄
rcodezero.py
(18.44 KB)
📄
route53.py
(20.73 KB)
📄
softlayer.py
(7.3 KB)
📄
vultr.py
(11.7 KB)
📄
worldwidedns.py
(18.5 KB)
📄
zerigo.py
(17.84 KB)
📄
zonomi.py
(10.91 KB)
Editing: buddyns.py
# Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You 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. """ BuddyNS DNS Driver """ try: import simplejson as json except ImportError: import json from libcloud.dns.types import Provider, ZoneDoesNotExistError,\ ZoneAlreadyExistsError from libcloud.dns.base import DNSDriver, Zone from libcloud.common.buddyns import BuddyNSConnection, BuddyNSResponse,\ BuddyNSException __all__ = [ 'BuddyNSDNSDriver' ] class BuddyNSDNSResponse(BuddyNSResponse): pass class BuddyNSDNSConnection(BuddyNSConnection): responseCls = BuddyNSDNSResponse class BuddyNSDNSDriver(DNSDriver): name = 'BuddyNS DNS' website = 'https://www.buddyns.com' type = Provider.BUDDYNS connectionCls = BuddyNSDNSConnection def list_zones(self): action = '/api/v2/zone/' response = self.connection.request(action=action, method='GET') zones = self._to_zones(items=response.parse_body()) return zones def get_zone(self, zone_id): """ :param zone_id: Zone domain name (e.g. example.com) :return: :class:`Zone` """ action = '/api/v2/zone/%s' % zone_id try: response = self.connection.request(action=action, method='GET') except BuddyNSException as e: if e.message == 'Not found': raise ZoneDoesNotExistError(value=e.message, driver=self, zone_id=zone_id) else: raise e zone = self._to_zone(response.parse_body()) return zone def create_zone(self, domain, type='master', ttl=None, extra=None): """ :param domain: Zone domain name (e.g. example.com) :type domain: ``str`` :param type: Zone type (This is not really used. See API docs for \ extra parameters) :type type: ``str`` :param ttl: TTL for new records (This is used through the extra param) :type ttl: ``int`` :param extra: Extra attributes that are specific to the driver such as ttl. :type extra: ``dict`` :rtype: :class:`Zone` Do not forget to pass the master in extra, extra = {'master':'65.55.37.62'} for example. """ action = '/api/v2/zone/' data = {'name': domain} if extra is not None: data.update(extra) post_data = json.dumps(data) try: response = self.connection.request(action=action, method='POST', data=post_data) except BuddyNSException as e: if e.message == 'Invalid zone submitted for addition.': raise ZoneAlreadyExistsError(value=e.message, driver=self, zone_id=domain) else: raise e zone = self._to_zone(response.parse_body()) return zone def delete_zone(self, zone): """ :param zone: Zone to be deleted. :type zone: :class:`Zone` :return: Boolean """ action = '/api/v2/zone/%s' % zone.domain try: self.connection.request(action=action, method='DELETE') except BuddyNSException as e: if e.message == 'Not found': raise ZoneDoesNotExistError(value=e.message, driver=self, zone_id=zone.id) else: raise e return True def _to_zone(self, item): common_keys = ['name', ] extra = {} for key in item: if key not in common_keys: extra[key] = item.get(key) zone = Zone(domain=item['name'], id=item['name'], type=None, extra=extra, ttl=None, driver=self) return zone def _to_zones(self, items): zones = [] for item in items: zones.append(self._to_zone(item)) return zones
Upload File
Create Folder