def patch(self, request, object_id): allowed_fields = ('pf_limit_states', 'pf_limit_frags', 'pf_limit_src', 'pf_custom_config', 'gateway', 'gateway_ipv6', 'static_routes', 'management_ip', 'pstats_forwarders') try: for key in request.JSON.keys(): if key not in allowed_fields: return JsonResponse({ 'error': _("Attribute not allowed : '{}'." "Allowed attributes are {}".format( key, allowed_fields)) }) return cluster_edit(request, object_id, api=True, update=True) except Exception as e: logger.critical(e, exc_info=1) error = _("An error has occurred") if settings.DEV_MODE: error = str(e) return JsonResponse({'error': error}, status=500)
def put(self, request, object_id): try: return cluster_edit(request, object_id, api=True) except Exception as e: logger.critical(e, exc_info=1) error = _("An error has occurred") if settings.DEV_MODE: error = str(e) return JsonResponse({'error': error}, status=500)
def post(self, request, object_id, action=None): try: if not action: return cluster_edit(request, object_id, api=True) if action and not object_id: return JsonResponse({'error': _('You must specify an ID')}, status=401) if action not in list(COMMAND_LIST.keys()): return JsonResponse({'error': _('Action not allowed')}, status=403) return COMMAND_LIST[action](request, object_id, api=True) except Exception as e: logger.critical(e, exc_info=1) if settings.DEV_MODE: error = str(e) else: error = _("An error has occurred") return JsonResponse({'error': error}, status=500)