Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(api): prefix class names on events actions #12354

Merged
merged 2 commits into from
Jan 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions superset/annotation_layers/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,11 @@ class AnnotationLayerRestApi(BaseSupersetModelRestApi):
@protect()
@safe
@statsd_metrics
@event_logger.log_this_with_context(
action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.delete",
log_to_statsd=False,
)
@permission_name("delete")
@event_logger.log_this_with_context(log_to_statsd=False)
def delete(self, pk: int) -> Response:
"""Delete an annotation layer
---
Expand Down Expand Up @@ -163,7 +166,10 @@ def delete(self, pk: int) -> Response:
@safe
@statsd_metrics
@permission_name("post")
@event_logger.log_this_with_context(log_to_statsd=False)
@event_logger.log_this_with_context(
action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.post",
log_to_statsd=False,
)
def post(self) -> Response:
"""Creates a new Annotation Layer
---
Expand Down Expand Up @@ -223,7 +229,10 @@ def post(self) -> Response:
@safe
@statsd_metrics
@permission_name("put")
@event_logger.log_this_with_context(log_to_statsd=False)
@event_logger.log_this_with_context(
action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.put",
log_to_statsd=False,
)
def put(self, pk: int) -> Response:
"""Updates an Annotation Layer
---
Expand Down Expand Up @@ -290,7 +299,10 @@ def put(self, pk: int) -> Response:
@safe
@statsd_metrics
@rison(get_delete_ids_schema)
@event_logger.log_this_with_context(log_to_statsd=False)
@event_logger.log_this_with_context(
action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.bulk_delete",
log_to_statsd=False,
)
def bulk_delete(self, **kwargs: Any) -> Response:
"""Delete bulk Annotation layers
---
Expand Down
64 changes: 52 additions & 12 deletions superset/charts/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,10 @@ def __init__(self) -> None:
@protect()
@safe
@statsd_metrics
@event_logger.log_this_with_context(log_to_statsd=False)
@event_logger.log_this_with_context(
action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.post",
log_to_statsd=False,
)
def post(self) -> Response:
"""Creates a new Chart
---
Expand Down Expand Up @@ -282,7 +285,10 @@ def post(self) -> Response:
@protect()
@safe
@statsd_metrics
@event_logger.log_this_with_context(log_to_statsd=False)
@event_logger.log_this_with_context(
action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.put",
log_to_statsd=False,
)
def put(self, pk: int) -> Response:
"""Changes a Chart
---
Expand Down Expand Up @@ -356,7 +362,10 @@ def put(self, pk: int) -> Response:
@protect()
@safe
@statsd_metrics
@event_logger.log_this_with_context(log_to_statsd=False)
@event_logger.log_this_with_context(
action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.delete",
log_to_statsd=False,
)
def delete(self, pk: int) -> Response:
"""Deletes a Chart
---
Expand Down Expand Up @@ -407,7 +416,10 @@ def delete(self, pk: int) -> Response:
@safe
@statsd_metrics
@rison(get_delete_ids_schema)
@event_logger.log_this_with_context(log_to_statsd=False)
@event_logger.log_this_with_context(
action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.bulk_delete",
log_to_statsd=False,
)
def bulk_delete(self, **kwargs: Any) -> Response:
"""Delete bulk Charts
---
Expand Down Expand Up @@ -495,7 +507,10 @@ def get_data_response(
@protect()
@safe
@statsd_metrics
@event_logger.log_this_with_context(log_to_statsd=False)
@event_logger.log_this_with_context(
action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.data",
log_to_statsd=False,
)
def data(self) -> Response:
"""
Takes a query context constructed in the client and returns payload
Expand Down Expand Up @@ -571,10 +586,14 @@ def data(self) -> Response:
return self.get_data_response(command)

@expose("/data/<cache_key>", methods=["GET"])
@event_logger.log_this
@protect()
@safe
@statsd_metrics
@event_logger.log_this_with_context(
action=lambda self, *args, **kwargs: f"{self.__class__.__name__}"
f".data_from_cache",
log_to_statsd=False,
)
def data_from_cache(self, cache_key: str) -> Response:
"""
Takes a query context cache key and returns payload
Expand Down Expand Up @@ -629,7 +648,11 @@ def data_from_cache(self, cache_key: str) -> Response:
@rison(screenshot_query_schema)
@safe
@statsd_metrics
@event_logger.log_this_with_context(log_to_statsd=False)
@event_logger.log_this_with_context(
action=lambda self, *args, **kwargs: f"{self.__class__.__name__}"
f".cache_screenshot",
log_to_statsd=False,
)
def cache_screenshot(self, pk: int, **kwargs: Dict[str, bool]) -> WerkzeugResponse:
"""
---
Expand Down Expand Up @@ -701,7 +724,10 @@ def trigger_celery() -> WerkzeugResponse:
@protect()
@safe
@statsd_metrics
@event_logger.log_this_with_context(log_to_statsd=False)
@event_logger.log_this_with_context(
action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.screenshot",
log_to_statsd=False,
)
def screenshot(self, pk: int, digest: str) -> WerkzeugResponse:
"""Get Chart screenshot
---
Expand Down Expand Up @@ -755,7 +781,10 @@ def screenshot(self, pk: int, digest: str) -> WerkzeugResponse:
@rison(thumbnail_query_schema)
@safe
@statsd_metrics
@event_logger.log_this_with_context(log_to_statsd=False)
@event_logger.log_this_with_context(
action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.thumbnail",
log_to_statsd=False,
)
def thumbnail(
self, pk: int, digest: str, **kwargs: Dict[str, bool]
) -> WerkzeugResponse:
Expand Down Expand Up @@ -829,7 +858,10 @@ def thumbnail(
@safe
@statsd_metrics
@rison(get_export_ids_schema)
@event_logger.log_this_with_context(log_to_statsd=False)
@event_logger.log_this_with_context(
action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.export",
log_to_statsd=False,
)
def export(self, **kwargs: Any) -> Response:
"""Export charts
---
Expand Down Expand Up @@ -885,9 +917,13 @@ def export(self, **kwargs: Any) -> Response:
@expose("/favorite_status/", methods=["GET"])
@protect()
@safe
@statsd_metrics
@rison(get_fav_star_ids_schema)
@event_logger.log_this_with_context(log_to_statsd=False)
@statsd_metrics
@event_logger.log_this_with_context(
action=lambda self, *args, **kwargs: f"{self.__class__.__name__}"
f".favorite_status",
log_to_statsd=False,
)
def favorite_status(self, **kwargs: Any) -> Response:
"""Favorite stars for Charts
---
Expand Down Expand Up @@ -932,6 +968,10 @@ def favorite_status(self, **kwargs: Any) -> Response:
@protect()
@safe
@statsd_metrics
@event_logger.log_this_with_context(
action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.import_",
log_to_statsd=False,
)
def import_(self) -> Response:
"""Import chart(s) with associated datasets and databases
---
Expand Down
5 changes: 4 additions & 1 deletion superset/css_templates/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,11 @@ class CssTemplateRestApi(BaseSupersetModelRestApi):
@protect()
@safe
@statsd_metrics
@event_logger.log_this_with_context(
action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.bulk_delete",
log_to_statsd=False,
)
@rison(get_delete_ids_schema)
@event_logger.log_this_with_context(log_to_statsd=False)
def bulk_delete(self, **kwargs: Any) -> Response:
"""Delete bulk CSS Templates
---
Expand Down
40 changes: 33 additions & 7 deletions superset/dashboards/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,10 @@ def __init__(self) -> None:
@protect()
@safe
@statsd_metrics
@event_logger.log_this_with_context(log_to_statsd=False)
@event_logger.log_this_with_context(
action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.post",
log_to_statsd=False,
)
def post(self) -> Response:
"""Creates a new Dashboard
---
Expand Down Expand Up @@ -273,7 +276,10 @@ def post(self) -> Response:
@protect()
@safe
@statsd_metrics
@event_logger.log_this_with_context(log_to_statsd=False)
@event_logger.log_this_with_context(
action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.put",
log_to_statsd=False,
)
def put(self, pk: int) -> Response:
"""Changes a Dashboard
---
Expand Down Expand Up @@ -344,7 +350,10 @@ def put(self, pk: int) -> Response:
@protect()
@safe
@statsd_metrics
@event_logger.log_this_with_context(log_to_statsd=False)
@event_logger.log_this_with_context(
action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.delete",
log_to_statsd=False,
)
def delete(self, pk: int) -> Response:
"""Deletes a Dashboard
---
Expand Down Expand Up @@ -395,7 +404,10 @@ def delete(self, pk: int) -> Response:
@safe
@statsd_metrics
@rison(get_delete_ids_schema)
@event_logger.log_this_with_context(log_to_statsd=False)
@event_logger.log_this_with_context(
action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.bulk_delete",
log_to_statsd=False,
)
def bulk_delete(self, **kwargs: Any) -> Response:
"""Delete bulk Dashboards
---
Expand Down Expand Up @@ -453,7 +465,10 @@ def bulk_delete(self, **kwargs: Any) -> Response:
@safe
@statsd_metrics
@rison(get_export_ids_schema)
@event_logger.log_this_with_context(log_to_statsd=False)
@event_logger.log_this_with_context(
action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.export",
log_to_statsd=False,
)
def export(self, **kwargs: Any) -> Response:
"""Export dashboards
---
Expand Down Expand Up @@ -529,7 +544,10 @@ def export(self, **kwargs: Any) -> Response:
@protect()
@safe
@rison(thumbnail_query_schema)
@event_logger.log_this_with_context(log_to_statsd=False)
@event_logger.log_this_with_context(
action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.thumbnail",
log_to_statsd=False,
)
def thumbnail(
self, pk: int, digest: str, **kwargs: Dict[str, bool]
) -> WerkzeugResponse:
Expand Down Expand Up @@ -617,7 +635,11 @@ def thumbnail(
@safe
@statsd_metrics
@rison(get_fav_star_ids_schema)
@event_logger.log_this_with_context(log_to_statsd=False)
@event_logger.log_this_with_context(
action=lambda self, *args, **kwargs: f"{self.__class__.__name__}"
f".favorite_status",
log_to_statsd=False,
)
def favorite_status(self, **kwargs: Any) -> Response:
"""Favorite Stars for Dashboards
---
Expand Down Expand Up @@ -662,6 +684,10 @@ def favorite_status(self, **kwargs: Any) -> Response:
@protect()
@safe
@statsd_metrics
@event_logger.log_this_with_context(
action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.import_",
log_to_statsd=False,
)
def import_(self) -> Response:
"""Import dashboard(s) with associated charts/datasets/databases
---
Expand Down
Loading