def list_changes(project_id, zone_name): client = dns.Client(project=project_id) zone = client.zone(zone_name, None) changes, _ = zone.list_changes() return [(change.started, change.status) for change in changes]
def client(cloud_config): client = dns.Client(cloud_config.project) yield client # Delete anything created during the test. for zone in client.list_zones()[0]: zone.delete()
def create_zone(project_id, name, dns_name, description): client = dns.Client(project=project_id) zone = client.zone( name, # examplezonename dns_name=dns_name) # example.com. zone.description = description zone.create() return zone
def get_zone(project_id, name): client = dns.Client(project=project_id) zone = client.zone(name=name) try: zone.reload() return zone except NotFound: return None
def list_resource_records(project_id, zone_name): client = dns.Client(project=project_id) zone = client.zone(zone_name, None) records, page_token = zone.list_resource_record_sets() while page_token is not None: next_batch, page_token = zone.list_resource_record_sets( page_token=page_token) records.extend(next_batch) return [(record.name, record.record_type, record.ttl, record.rrdatas) for record in records]
def delete_zone(project_id, name): client = dns.Client(project=project_id) zone = client.zone(name, None) zone.delete()
def list_zones(project_id): client = dns.Client(project=project_id) zones, _ = client.list_zones() return [zone.name for zone in zones]
def get_zone(project_id, name): client = dns.Client(project=project_id) zones, _ = client.list_zones() zone = list(filter(lambda zone: zone.name == name, zones)) return zone.pop() if zone else None