def delete(self, request, id, **kwargs):
     context = request.context
     self._check_admin(context)
     snmp_cred = db.get_snmp_cred_by_id(context, id)
     netconf_cred = db.get_netconf_cred_by_id(context, id)
     if snmp_cred:
         db.delete_snmp_cred_by_id(context, id)
     elif netconf_cred:
         db.delete_netconf_cred_by_id(context, id)
     else:
         raise webob.exc.HTTPNotFound(
             _("Credential with id=%s does not exist") % id)
 def delete(self, request, id, **kwargs):
     context = request.context
     self._check_admin(context)
     filters = {"credentials": id}
     switch_exists = db.get_if_bnp_phy_switch_exists(context, **filters)
     if switch_exists:
         raise webob.exc.HTTPConflict(
             _("credential with id=%s is associated with a switch." "Hence can't be deleted.") % id
         )
     snmp_cred = db.get_snmp_cred_by_id(context, id)
     netconf_cred = db.get_netconf_cred_by_id(context, id)
     if snmp_cred:
         db.delete_snmp_cred_by_id(context, id)
     elif netconf_cred:
         db.delete_netconf_cred_by_id(context, id)
     else:
         raise webob.exc.HTTPNotFound(_("Credential with id=%s does not exist") % id)
 def delete(self, request, id, **kwargs):
     context = request.context
     self._check_admin(context)
     filters = {'credentials': id}
     switch_exists = db.get_if_bnp_phy_switch_exists(context, **filters)
     if switch_exists:
         raise webob.exc.HTTPConflict(
             _("credential with id=%s is associated with a switch."
               "Hence can't be deleted.") % id)
     snmp_cred = db.get_snmp_cred_by_id(context, id)
     netconf_cred = db.get_netconf_cred_by_id(context, id)
     if snmp_cred:
         db.delete_snmp_cred_by_id(context, id)
     elif netconf_cred:
         db.delete_netconf_cred_by_id(context, id)
     else:
         raise webob.exc.HTTPNotFound(
             _("Credential with id=%s does not exist") % id)