1717import logging
1818
1919from flask import request , Response
20- from flask_appbuilder .api import BaseApi , expose , protect , safe
20+ from flask_appbuilder .api import expose , protect , safe
2121from marshmallow import ValidationError
2222
23- from superset .constants import MODEL_API_RW_METHOD_PERMISSION_MAP , RouteMethod
23+ from superset .constants import MODEL_API_RW_METHOD_PERMISSION_MAP
2424from superset .explore .form_data .commands .create import CreateFormDataCommand
2525from superset .explore .form_data .commands .delete import DeleteFormDataCommand
2626from superset .explore .form_data .commands .get import GetFormDataCommand
3232 TemporaryCacheAccessDeniedError ,
3333 TemporaryCacheResourceNotFoundError ,
3434)
35- from superset .views .base_api import requires_json
35+ from superset .views .base_api import BaseSupersetApi , requires_json , statsd_metrics
3636
3737logger = logging .getLogger (__name__ )
3838
3939
40- class ExploreFormDataRestApi (BaseApi ):
40+ class ExploreFormDataRestApi (BaseSupersetApi ):
4141 add_model_schema = FormDataPostSchema ()
4242 edit_model_schema = FormDataPutSchema ()
4343 method_permission_name = MODEL_API_RW_METHOD_PERMISSION_MAP
44- include_route_methods = {
45- RouteMethod .POST ,
46- RouteMethod .PUT ,
47- RouteMethod .GET ,
48- RouteMethod .DELETE ,
49- }
5044 allow_browser_login = True
5145 class_permission_name = "ExploreFormDataRestApi"
5246 resource_name = "explore"
@@ -56,6 +50,7 @@ class ExploreFormDataRestApi(BaseApi):
5650 @expose ("/form_data" , methods = ["POST" ])
5751 @protect ()
5852 @safe
53+ @statsd_metrics
5954 @event_logger .log_this_with_context (
6055 action = lambda self , * args , ** kwargs : f"{ self .__class__ .__name__ } .post" ,
6156 log_to_statsd = False ,
@@ -120,6 +115,7 @@ def post(self) -> Response:
120115 @expose ("/form_data/<string:key>" , methods = ["PUT" ])
121116 @protect ()
122117 @safe
118+ @statsd_metrics
123119 @event_logger .log_this_with_context (
124120 action = lambda self , * args , ** kwargs : f"{ self .__class__ .__name__ } .put" ,
125121 log_to_statsd = True ,
@@ -193,6 +189,7 @@ def put(self, key: str) -> Response:
193189 @expose ("/form_data/<string:key>" , methods = ["GET" ])
194190 @protect ()
195191 @safe
192+ @statsd_metrics
196193 @event_logger .log_this_with_context (
197194 action = lambda self , * args , ** kwargs : f"{ self .__class__ .__name__ } .get" ,
198195 log_to_statsd = True ,
@@ -244,6 +241,7 @@ def get(self, key: str) -> Response:
244241 @expose ("/form_data/<string:key>" , methods = ["DELETE" ])
245242 @protect ()
246243 @safe
244+ @statsd_metrics
247245 @event_logger .log_this_with_context (
248246 action = lambda self , * args , ** kwargs : f"{ self .__class__ .__name__ } .delete" ,
249247 log_to_statsd = True ,
0 commit comments