def METHOD_NAME(self, request, agent_id, svcname):
    agent = get_object_or_404(Agent, agent_id=agent_id)
    if agent.is_posix:
        return notify_error("Please use 'Recover Connection' instead.")
    action = request.data["sv_action"]
    data = {
        "func": "winsvcaction",
        "payload": {
            "name": svcname,
        },
    }
    # response struct from agent: {success: bool, errormsg: string}
    if action == "restart":
        data["payload"]["action"] = "stop"
        r = asyncio.run(agent.nats_cmd(data, timeout=32))
        success, natserror, errormsg = process_nats_response(r)
        if errormsg == "timeout" or natserror:
            return notify_error("Unable to contact the agent")
        elif not success and errormsg:
            return notify_error(errormsg)
        elif success:
            data["payload"]["action"] = "start"
            r = asyncio.run(agent.nats_cmd(data, timeout=32))
            success, natserror, errormsg = process_nats_response(r)
            if errormsg == "timeout" or natserror:
                return notify_error("Unable to contact the agent")
            elif not success and errormsg:
                return notify_error(errormsg)
            elif success:
                return Response("The service was restarted successfully")
    else:
        data["payload"]["action"] = action
        r = asyncio.run(agent.nats_cmd(data, timeout=32))
        success, natserror, errormsg = process_nats_response(r)
        if errormsg == "timeout" or natserror:
            return notify_error("Unable to contact the agent")
        elif not success and errormsg:
            return notify_error(errormsg)
        elif success:
            return Response(
                f"The service was {'started' if action == 'start' else 'stopped'} successfully"
            )
    return notify_error("Something went wrong")