parameters: (self, request, pk=None)
docstring: Delete agent
  
          :param request: destory parameter
          :param pk: primary key
          :return: none
          :rtype: rest_framework.status
docstring_summary: Delete agent
docstring_tokens: Delete agent
function: def destroy(self, request, pk=None):
          """
          Delete agent
  
          :param request: destory parameter
          :param pk: primary key
          :return: none
          :rtype: rest_framework.status
          """
          try:
              try:
                  if request.user.is_admin:
                      agent = Agent.objects.get(id=pk)
                  else:
                      raise CustomError("User can't delete agent！")
              except ObjectDoesNotExist:
                  raise ResourceNotFound
              else:
                  if agent.node.count():
                      raise ResourceInUse
                  agent.delete()
  
                  return Response(ok(None), status=status.HTTP_202_ACCEPTED)
          except (ResourceNotFound, ResourceInUse) as e:
              raise e
          except Exception as e:
              return Response(
                  err(e.args), status=status.HTTP_400_BAD_REQUEST
              )
function_tokens: def destroy ( self , request , pk = None ) : try : try : if request . user . is_admin : agent = Agent . objects . get ( id = pk ) else : raise CustomError ( "User can't delete agent！") except ObjectDoesNotExist : raise ResourceNotFound else : if agent . node . count ( ) : raise ResourceInUse agent . delete ( ) return Response ( ok ( None ) , status = status . HTTP_202_ACCEPTED ) except ( ResourceNotFound , ResourceInUse ) as e : raise e except Exception as e : return Response ( err ( e . args ) , status = status . HTTP_400_BAD_REQUEST )