Antonio-RiveroMartnez commented on code in PR #31374:
URL: https://github.com/apache/superset/pull/31374#discussion_r1882350771
##########
superset/commands/dashboard/update.py:
##########
@@ -202,3 +203,29 @@ def run(self) -> Model:
)
return configuration
+
+
+class UpdateDashboardColorsConfigCommand(UpdateDashboardCommand):
+ @transaction(
Review Comment:
Isn't this decorator supposed to be used on the `def run`? hence no need to
disable the pylint rule about transaction
##########
superset/dashboards/api.py:
##########
@@ -767,6 +773,88 @@ def put_filters(self, pk: int) -> Response:
response = self.response_422(message=str(ex))
return response
+ @expose("/<pk>/colors", methods=("PUT",))
+ @protect()
+ @safe
+ @statsd_metrics
+ @event_logger.log_this_with_context(
+ action=lambda self, *args, **kwargs:
f"{self.__class__.__name__}.put_colors",
+ log_to_statsd=False,
+ )
+ @requires_json
+ def put_colors(self, pk: int) -> Response:
+ """
+ Modify colors configuration for a dashboard.
+ ---
+ put:
+ summary: Update colors configuration for a dashboard.
+ parameters:
+ - in: path
+ schema:
+ type: integer
+ name: pk
+ - in: query
+ name: mark_updated
+ schema:
+ type: boolean
+ description: Whether to update the dashboard changed_on field
+ requestBody:
+ description: Colors configuration
+ required: true
+ content:
+ application/json:
+ schema:
+ $ref:
'#/components/schemas/DashboardColorsConfigUpdateSchema'
+ responses:
+ 200:
+ description: Dashboard colors updated
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ result:
+ type: array
+ 400:
+ $ref: '#/components/responses/400'
+ 401:
+ $ref: '#/components/responses/401'
+ 403:
+ $ref: '#/components/responses/403'
+ 404:
+ $ref: '#/components/responses/404'
+ 422:
+ $ref: '#/components/responses/422'
+ 500:
+ $ref: '#/components/responses/500'
+ """
+ try:
+ item = self.update_colors_model_schema.load(request.json,
partial=True)
Review Comment:
Since we can send just partial updates, isn't better to use a PATCH call
instead?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]