debian-mirror-gitlab/lib/api/metrics/user_starred_dashboards.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

66 lines
2.3 KiB
Ruby
Raw Normal View History

2020-05-24 23:13:21 +05:30
# frozen_string_literal: true
module API
module Metrics
2021-01-03 14:25:43 +05:30
class UserStarredDashboards < ::API::Base
2021-01-29 00:20:46 +05:30
feature_category :metrics
2022-07-23 23:45:48 +05:30
urgency :low
2021-01-29 00:20:46 +05:30
2023-01-13 00:05:48 +05:30
USER_STARRED_DASHBOARDS_TAGS = %w[user_starred_dashboards].freeze
2020-05-24 23:13:21 +05:30
resource :projects do
2023-01-13 00:05:48 +05:30
desc 'Add a star to a dashboard' do
detail 'Marks selected metrics dashboard as starred. Introduced in GitLab 13.0.'
2020-05-24 23:13:21 +05:30
success Entities::Metrics::UserStarredDashboard
2023-01-13 00:05:48 +05:30
failure [
{ code: 400, message: 'Bad request' },
{ code: 404, message: 'Not found' }
]
tags USER_STARRED_DASHBOARDS_TAGS
2020-05-24 23:13:21 +05:30
end
params do
requires :dashboard_path, type: String, allow_blank: false, coerce_with: ->(val) { CGI.unescape(val) },
2023-01-13 00:05:48 +05:30
desc: 'URL-encoded path to file defining the dashboard which should be marked as favorite'
2020-05-24 23:13:21 +05:30
end
post ':id/metrics/user_starred_dashboards' do
result = ::Metrics::UsersStarredDashboards::CreateService.new(current_user, user_project, params[:dashboard_path]).execute
if result.success?
present result.payload, with: Entities::Metrics::UserStarredDashboard
else
error!({ errors: result.message }, 400)
end
end
2023-01-13 00:05:48 +05:30
desc 'Remove a star from a dashboard' do
detail 'Remove star from selected metrics dashboard. Introduced in GitLab 13.0.'
success code: 200
failure [
{ code: 400, message: 'Bad request' },
{ code: 404, message: 'Not found' }
]
tags USER_STARRED_DASHBOARDS_TAGS
end
2020-05-24 23:13:21 +05:30
params do
optional :dashboard_path, type: String, allow_blank: false, coerce_with: ->(val) { CGI.unescape(val) },
2022-08-27 11:52:29 +05:30
desc: 'Url encoded path to a file defining the dashboard from which the star should be removed'
2020-05-24 23:13:21 +05:30
end
delete ':id/metrics/user_starred_dashboards' do
result = ::Metrics::UsersStarredDashboards::DeleteService.new(current_user, user_project, params[:dashboard_path]).execute
if result.success?
status :ok
result.payload
else
status :bad_request
end
end
end
end
end
end