Remove an AS number.

            * `auth` [BaseAuth]
                AAA options.
            * `spec` [asn]
                An ASN specification.

            Remove ASNs matching the `asn` argument.

            This is the documentation of the internal backend function. It's
            exposed over XML-RPC, please also see the XML-RPC documentation for
            :py:func:`nipap.xmlrpc.NipapXMLRPC.remove_asn` for full
            understanding.

def remove_asn(self, auth, asn):
        """ Remove an AS number.

            * `auth` [BaseAuth]
                AAA options.
            * `spec` [asn]
                An ASN specification.

            Remove ASNs matching the `asn` argument.

            This is the documentation of the internal backend function. It's
            exposed over XML-RPC, please also see the XML-RPC documentation for
            :py:func:`nipap.xmlrpc.NipapXMLRPC.remove_asn` for full
            understanding.
        """

        self._logger.debug("remove_asn called; asn: %s" % unicode(asn))

        # get list of ASNs to remove before removing them
        asns = self.list_asn(auth, asn)

        # remove
        where, params = self._expand_asn_spec(asn)
        sql = "DELETE FROM ip_net_asn WHERE " + where
        self._execute(sql, params)

        # write to audit table
        for a in asns:
            audit_params = {
                'username': auth.username,
                'authenticated_as': auth.authenticated_as,
                'full_name': auth.full_name,
                'authoritative_source': auth.authoritative_source,
                'description': 'Removed ASN %s' % unicode(a['asn'])
            }
            sql, params = self._sql_expand_insert(audit_params)
            self._execute('INSERT INTO ip_net_log %s' % sql, params)