Works through the zone, deleting each page of rrsets, except the zone's SOA and the NS rrsets.
Once the zone is cleared, it can be deleted.

<p/>Users can modify the zone's SOA and NS rrsets, but they cannot be deleted except via
deleting the zone.
180989
private void deleteEverythingExceptNSAndSOA(String id, String name) {
    List<ActionOnResourceRecordSet> deletes = new ArrayList<ActionOnResourceRecordSet>();
    ResourceRecordSetList page = api.listResourceRecordSets(id);
    while (!page.isEmpty()) {
      for (ResourceRecordSet<?> rrset : page) {
        if (rrset.type().equals("SOA") || rrset.type().equals("NS") && rrset.name().equals(name)) {
          continue;
        }
        deletes.add(ActionOnResourceRecordSet.delete(rrset));
      }
      if (!deletes.isEmpty()) {
        api.changeResourceRecordSets(id, deletes);
      }
      if (page.next == null) {
        page.clear();
      } else {
        deletes.clear();
        page = api.listResourceRecordSets(id, page.next.name, page.next.type, page.next.identifier);
      }
    }
  }
1232177
synchronized void cleanUp() {

        updateAccessCounts();

        int                          removeCount = size() / 2;
        int accessTarget = getAccessCountCeiling(removeCount, removeCount / 8);
        BaseHashMap.BaseHashIterator it          = new BaseHashIterator();
        int                          savecount   = 0;

        for (; it.hasNext(); ) {
            CachedObject r = (CachedObject) it.next();

            if (it.getAccessCount() <= accessTarget) {
                synchronized (r) {
                    if (!r.isKeepInMemory()) {
                        r.setInMemory(false);

                        if (r.hasChanged()) {
                            rowTable[savecount++] = r;
                        }

                        it.remove();

                        cacheBytesLength -= r.getStorageSize();

                        removeCount--;
                    }
                }
            }
        }

        if (removeCount > 50) {
            it = new BaseHashIterator();

            for (; removeCount >= 0 && it.hasNext(); ) {
                CachedObject r = (CachedObject) it.next();

                if (!r.isKeepInMemory()) {
                    r.setInMemory(false);

                    if (r.hasChanged()) {
                        rowTable[savecount++] = r;
                    }

                    it.remove();

                    cacheBytesLength -= r.getStorageSize();

                    removeCount--;
                }
            }
        }

        super.setAccessCountFloor(accessTarget);
        saveRows(savecount);
    }
1074988
public void deleteStates(Collection<MutableState> statesToDelete) {
    if (statesToDelete.isEmpty()) {
      return;
    }
    for (MutableState state : statesToDelete) {
      deleteState(state);
    }
    remapStateIds();
  }
504839
public boolean remove(SpdData data) {
        if (data == null)
            return false;
        if (data instanceof SpdStat) {
            return super.remove(data);
        } else {
            return false;
        }
    }
385688
static private boolean deleteIsTruncate(ParsedDeleteStmt stmt, AbstractPlanNode plan) {
        if (!(plan instanceof SeqScanPlanNode)) {
            return false;
        }

        // Assume all index scans have filters in this context, so only consider seq scans.
        SeqScanPlanNode seqScanNode = (SeqScanPlanNode)plan;
        if (seqScanNode.getPredicate() != null) {
            return false;
        }

        if (stmt.hasLimitOrOffset()) {
            return false;
        }

        return true;
    }
890302
public function onAfterDelete()
    {
        parent::onAfterDelete();
        if (Versioned::get_stage() == 'Stage') {
            $this->Pages()->removeAll();
            $this->BlockSets()->removeAll();
        }
    }
410187
public void free()
    {
    	if (m_recordOwnerCollection != null)
    		m_recordOwnerCollection.free();
    	m_recordOwnerCollection = null;
        if (m_application != null)
            m_application.removeTask(this);   // Remove this session from the list
    }
1194544
public void clear() {
		domainsFileLock.writeLock().lock();
		logger.trace("LOCK writelock");
		allDomains = null;
		domainMap = null;
		logger.trace("UNLOCK writelock");
		domainsFileLock.writeLock().unlock();
	}
48705
private void doDelete() throws PageException, SearchException {
	required("index", action, "collection", collection);
	if (type != SearchIndex.TYPE_CUSTOM) required("index", action, "key", key);

	// no type defined
	if (type == -1) {
	    if (query != null) {
		type = SearchIndex.TYPE_CUSTOM;
	    }
	    else {
		Resource file = null;
		try {
		    file = ResourceUtil.toResourceExisting(pageContext, key);
		    pageContext.getConfig().getSecurityManager().checkFileLocation(file);
		}
		catch (ExpressionException e) {}

		if (file != null && file.exists() && file.isFile()) type = SearchIndex.TYPE_FILE;
		else if (file != null && file.exists() && file.isDirectory()) type = SearchIndex.TYPE_PATH;
		else {
		    try {
			new URL(key);
			type = SearchIndex.TYPE_URL;
		    }
		    catch (MalformedURLException e) {}
		}
	    }
	}

	collection.deleteIndex(pageContext, key, type, query);
    }
370765
def delete(self):
        
        method = 'flickr.photosets.delete'

        _dopost(method, auth=True, photoset_id=self.id)
        return True
463463
def delete_resource(resource_name, key, identifier_fields, profile='pagerduty', subdomain=None, api_key=None):
    '''
    

    '''
    resource = get_resource(resource_name, key, identifier_fields, profile, subdomain, api_key)
    if resource:
        if __opts__['test']:
            return 'would delete'
        # flush the resource_cache, because we're modifying a resource
        del __context__['pagerduty_util.resource_cache'][resource_name]
        resource_id = _get_resource_id(resource)
        return _query(method='DELETE', action='{0}/{1}'.format(resource_name, resource_id), profile=profile, subdomain=subdomain, api_key=api_key)
    else:
        return True
949641
private void doDelete() throws PageException {
	try {
	    RegistryQuery.deleteValue(branch, entry);
	}
	catch (Exception e) {
	    throw Caster.toPageException(e);
	}
    }
1112596
public static base_response delete(nitro_service client, String zonename) throws Exception {
		dnszone deleteresource = new dnszone();
		deleteresource.zonename = zonename;
		return deleteresource.delete_resource(client);
	}
1010453
def remove_dns_challenge_txt(self, zone_id, domain, txt_challenge):
        
        print("Deleting DNS challenge..")
        resp = self.route53.change_resource_record_sets(
            HostedZoneId=zone_id,
            ChangeBatch=self.get_dns_challenge_change_batch('DELETE', domain, txt_challenge)
        )

        return resp
700040
@Override
	public Result<Void> deleteNS(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp, String ns) {
		TimeTaken tt = trans.start(DELETE_NS + ' ' + ns, Env.SUB|Env.ALWAYS);
		try {
			Result<Void> rp = service.deleteNS(trans,ns);
			switch(rp.status) {
				case OK: 
					setContentType(resp,nsRequestDF.getOutType());
					return Result.ok();
				default:
					return Result.err(rp);
			}
		} catch (Exception e) {
			trans.error().log(e,IN,DELETE_NS);
			return Result.err(e);
		} finally {
			tt.done();
		}
	}
951201
public boolean onDelete()
    {
        Record record = this.getMainRecord();
        if (record == null)
            return false;

        if (record.getEditMode() == Constants.EDIT_NONE)
            return true;
        if (record.getEditMode() == Constants.EDIT_ADD)
        {   // If they're adding, can't delete nothing!
            this.onRefresh();
            return true;
        }
        try {
            if (record.getEditMode() != Constants.EDIT_IN_PROGRESS)
                record.edit();
            record.remove();
            record.addNew();
            this.clearStatusText();
        } catch(DBException ex) {
            this.displayError(ex);
            return false;
        }
        return true;
    }
916737
public function delete()
    {     
        Util::delTree( $this->getPath() );
        foreach (Server::enum() as $s) {
            $tname = str_replace( THEME_DIR.'/', '', $s->templateDir );
            if ($tname == $this->name) {
                $s->setTheme();
            }
        }
    }