diff --git a/Makefile b/Makefile index 9b6f63cada1..662e777ea1c 100644 --- a/Makefile +++ b/Makefile @@ -47,7 +47,7 @@ $(MERGED_SPEC_TARGET): $(SPEC_TARGET) $(NGALERT_SPEC_TARGET) $(SWAGGER) ## Merge SWAGGER_GENERATE_EXTENSION=false $(SWAGGER) generate spec -m -w pkg/server -o public/api-spec.json \ -x "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions" \ -x "github.com/prometheus/alertmanager" \ - -i pkg/api/docs/tags.json + -i pkg/api/swagger_tags.json swagger-api-spec: gen-go --swagger-api-spec $(MERGED_SPEC_TARGET) validate-api-spec diff --git a/pkg/api/admin.go b/pkg/api/admin.go index 2ebe625d398..c837733301c 100644 --- a/pkg/api/admin.go +++ b/pkg/api/admin.go @@ -10,6 +10,19 @@ import ( "github.com/grafana/grafana/pkg/setting" ) +// swagger:route GET /admin/settings admin adminGetSettings +// +// Fetch settings. +// +// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `settings:read` and scopes: `settings:*`, `settings:auth.saml:` and `settings:auth.saml:enabled` (property level). +// +// Security: +// - basic: +// +// Responses: +// 200: adminGetSettingsResponse +// 401: unauthorisedError +// 403: forbiddenError func (hs *HTTPServer) AdminGetSettings(c *models.ReqContext) response.Response { settings, err := hs.getAuthorizedSettings(c.Req.Context(), c.SignedInUser, hs.SettingsProvider.Current()) if err != nil { @@ -18,6 +31,18 @@ func (hs *HTTPServer) AdminGetSettings(c *models.ReqContext) response.Response { return response.JSON(http.StatusOK, settings) } +// swagger:route GET /admin/stats admin adminGetStats +// +// Fetch Grafana Stats. +// +// Only works with Basic Authentication (username and password). See introduction for an explanation. +// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `server:stats:read`. +// +// Responses: +// 200: adminGetStatsResponse +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) AdminGetStats(c *models.ReqContext) response.Response { statsQuery := models.GetAdminStatsQuery{} @@ -72,3 +97,15 @@ func (hs *HTTPServer) getAuthorizedSettings(ctx context.Context, user *models.Si } return authorizedBag, nil } + +// swagger:response adminGetSettingsResponse +type GetSettingsResponse struct { + // in:body + Body setting.SettingsBag `json:"body"` +} + +// swagger:response adminGetStatsResponse +type GetStatsResponse struct { + // in:body + Body models.AdminStats `json:"body"` +} diff --git a/pkg/api/admin_provisioning.go b/pkg/api/admin_provisioning.go index ba9f53f31cb..e9380d96ef1 100644 --- a/pkg/api/admin_provisioning.go +++ b/pkg/api/admin_provisioning.go @@ -8,6 +8,21 @@ import ( "github.com/grafana/grafana/pkg/models" ) +// swagger:route POST /admin/provisioning/dashboards/reload admin_provisioning adminProvisioningReloadDashboards +// +// Reload dashboard provisioning configurations. +// +// Reloads the provisioning config files for dashboards again. It won’t return until the new provisioned entities are already stored in the database. In case of dashboards, it will stop polling for changes in dashboard files and then restart it with new configurations after returning. +// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `provisioning:reload` and scope `provisioners:dashboards`. +// +// Security: +// - basic: +// +// Responses: +// 200: okResponse +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) AdminProvisioningReloadDashboards(c *models.ReqContext) response.Response { err := hs.ProvisioningService.ProvisionDashboards(c.Req.Context()) if err != nil && !errors.Is(err, context.Canceled) { @@ -16,6 +31,21 @@ func (hs *HTTPServer) AdminProvisioningReloadDashboards(c *models.ReqContext) re return response.Success("Dashboards config reloaded") } +// swagger:route POST /admin/provisioning/datasources/reload admin_provisioning adminProvisioningReloadDatasources +// +// Reload datasource provisioning configurations. +// +// Reloads the provisioning config files for datasources again. It won’t return until the new provisioned entities are already stored in the database. In case of dashboards, it will stop polling for changes in dashboard files and then restart it with new configurations after returning. +// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `provisioning:reload` and scope `provisioners:datasources`. +// +// Security: +// - basic: +// +// Responses: +// 200: okResponse +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) AdminProvisioningReloadDatasources(c *models.ReqContext) response.Response { err := hs.ProvisioningService.ProvisionDatasources(c.Req.Context()) if err != nil { @@ -24,6 +54,21 @@ func (hs *HTTPServer) AdminProvisioningReloadDatasources(c *models.ReqContext) r return response.Success("Datasources config reloaded") } +// swagger:route POST /admin/provisioning/plugins/reload admin_provisioning adminProvisioningReloadPlugins +// +// Reload plugin provisioning configurations. +// +// Reloads the provisioning config files for plugins again. It won’t return until the new provisioned entities are already stored in the database. In case of dashboards, it will stop polling for changes in dashboard files and then restart it with new configurations after returning. +// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `provisioning:reload` and scope `provisioners:plugin`. +// +// Security: +// - basic: +// +// Responses: +// 200: okResponse +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) AdminProvisioningReloadPlugins(c *models.ReqContext) response.Response { err := hs.ProvisioningService.ProvisionPlugins(c.Req.Context()) if err != nil { @@ -32,6 +77,21 @@ func (hs *HTTPServer) AdminProvisioningReloadPlugins(c *models.ReqContext) respo return response.Success("Plugins config reloaded") } +// swagger:route POST /admin/provisioning/notifications/reload admin_provisioning adminProvisioningReloadNotifications +// +// Reload legacy alert notifier provisioning configurations. +// +// Reloads the provisioning config files for legacy alert notifiers again. It won’t return until the new provisioned entities are already stored in the database. In case of dashboards, it will stop polling for changes in dashboard files and then restart it with new configurations after returning. +// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `provisioning:reload` and scope `provisioners:notifications`. +// +// Security: +// - basic: +// +// Responses: +// 200: okResponse +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) AdminProvisioningReloadNotifications(c *models.ReqContext) response.Response { err := hs.ProvisioningService.ProvisionNotifications(c.Req.Context()) if err != nil { diff --git a/pkg/api/admin_users.go b/pkg/api/admin_users.go index 56265711893..cb5739d44eb 100644 --- a/pkg/api/admin_users.go +++ b/pkg/api/admin_users.go @@ -15,6 +15,23 @@ import ( "github.com/grafana/grafana/pkg/web" ) +// swagger:route POST /admin/users admin_users adminCreateUser +// +// Create new user. +// +// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `users:create`. +// Note that OrgId is an optional parameter that can be used to assign a new user to a different organization when `auto_assign_org` is set to `true`. +// +// Security: +// - basic: +// +// Responses: +// 200: adminCreateUserResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 412: preconditionFailedError +// 500: internalServerError func (hs *HTTPServer) AdminCreateUser(c *models.ReqContext) response.Response { form := dtos.AdminCreateUserForm{} if err := web.Bind(c.Req, &form); err != nil { @@ -62,6 +79,21 @@ func (hs *HTTPServer) AdminCreateUser(c *models.ReqContext) response.Response { return response.JSON(http.StatusOK, result) } +// swagger:route PUT /admin/users/{user_id}/password admin_users adminUpdateUserPassword +// +// Set password for user. +// +// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `users.password:update` and scope `global.users:*`. +// +// Security: +// - basic: +// +// Responses: +// 200: okResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) AdminUpdateUserPassword(c *models.ReqContext) response.Response { form := dtos.AdminUpdateUserPasswordForm{} if err := web.Bind(c.Req, &form); err != nil { @@ -100,7 +132,19 @@ func (hs *HTTPServer) AdminUpdateUserPassword(c *models.ReqContext) response.Res return response.Success("User password updated") } -// PUT /api/admin/users/:id/permissions +// swagger:route PUT /admin/users/{user_id}/permissions admin_users adminUpdateUserPermissions +// +// Set permissions for user. +// +// Only works with Basic Authentication (username and password). See introduction for an explanation. +// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `users.permissions:update` and scope `global.users:*`. +// +// Responses: +// 200: okResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) AdminUpdateUserPermissions(c *models.ReqContext) response.Response { form := dtos.AdminUpdateUserPermissionsForm{} if err := web.Bind(c.Req, &form); err != nil { @@ -123,6 +167,21 @@ func (hs *HTTPServer) AdminUpdateUserPermissions(c *models.ReqContext) response. return response.Success("User permissions updated") } +// swagger:route DELETE /admin/users/{user_id} admin_users adminDeleteUser +// +// Delete global User. +// +// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `users:delete` and scope `global.users:*`. +// +// Security: +// - basic: +// +// Responses: +// 200: okResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) AdminDeleteUser(c *models.ReqContext) response.Response { userID, err := strconv.ParseInt(web.Params(c.Req)[":id"], 10, 64) if err != nil { @@ -141,7 +200,21 @@ func (hs *HTTPServer) AdminDeleteUser(c *models.ReqContext) response.Response { return response.Success("User deleted") } -// POST /api/admin/users/:id/disable +// swagger:route POST /admin/users/{user_id}/disable admin_users adminDisableUser +// +// Disable user. +// +// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `users:disable` and scope `global.users:1` (userIDScope). +// +// Security: +// - basic: +// +// Responses: +// 200: okResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) AdminDisableUser(c *models.ReqContext) response.Response { userID, err := strconv.ParseInt(web.Params(c.Req)[":id"], 10, 64) if err != nil { @@ -170,7 +243,21 @@ func (hs *HTTPServer) AdminDisableUser(c *models.ReqContext) response.Response { return response.Success("User disabled") } -// POST /api/admin/users/:id/enable +// swagger:route POST /admin/users/{user_id}/enable admin_users adminEnableUser +// +// Enable user. +// +// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `users:enable` and scope `global.users:1` (userIDScope). +// +// Security: +// - basic: +// +// Responses: +// 200: okResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) AdminEnableUser(c *models.ReqContext) response.Response { userID, err := strconv.ParseInt(web.Params(c.Req)[":id"], 10, 64) if err != nil { @@ -194,7 +281,21 @@ func (hs *HTTPServer) AdminEnableUser(c *models.ReqContext) response.Response { return response.Success("User enabled") } -// POST /api/admin/users/:id/logout +// swagger:route POST /admin/users/{user_id}/logout admin_users adminLogoutUser +// +// Logout user revokes all auth tokens (devices) for the user. User of issued auth tokens (devices) will no longer be logged in and will be required to authenticate again upon next activity. +// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `users.logout` and scope `global.users:*`. +// +// Security: +// - basic: +// +// Responses: +// 200: okResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) AdminLogoutUser(c *models.ReqContext) response.Response { userID, err := strconv.ParseInt(web.Params(c.Req)[":id"], 10, 64) if err != nil { @@ -208,7 +309,19 @@ func (hs *HTTPServer) AdminLogoutUser(c *models.ReqContext) response.Response { return hs.logoutUserFromAllDevicesInternal(c.Req.Context(), userID) } -// GET /api/admin/users/:id/auth-tokens +// swagger:route GET /admin/users/{user_id}/auth-tokens admin_users adminGetUserAuthTokens +// +// Return a list of all auth tokens (devices) that the user currently have logged in from. +// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `users.authtoken:list` and scope `global.users:*`. +// +// Security: +// - basic: +// +// Responses: +// 200: adminGetUserAuthTokensResponse +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) AdminGetUserAuthTokens(c *models.ReqContext) response.Response { userID, err := strconv.ParseInt(web.Params(c.Req)[":id"], 10, 64) if err != nil { @@ -217,7 +330,23 @@ func (hs *HTTPServer) AdminGetUserAuthTokens(c *models.ReqContext) response.Resp return hs.getUserAuthTokensInternal(c, userID) } -// POST /api/admin/users/:id/revoke-auth-token +// swagger:route POST /admin/users/{user_id}/revoke-auth-token admin_users adminRevokeUserAuthToken +// +// Revoke auth token for user. +// +// Revokes the given auth token (device) for the user. User of issued auth token (device) will no longer be logged in and will be required to authenticate again upon next activity. +// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `users.authtoken:update` and scope `global.users:*`. +// +// Security: +// - basic: +// +// Responses: +// 200: okResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) AdminRevokeUserAuthToken(c *models.ReqContext) response.Response { cmd := models.RevokeAuthTokenCmd{} if err := web.Bind(c.Req, &cmd); err != nil { @@ -229,3 +358,87 @@ func (hs *HTTPServer) AdminRevokeUserAuthToken(c *models.ReqContext) response.Re } return hs.revokeUserAuthTokenInternal(c, userID, cmd) } + +// swagger:parameters adminUpdateUserPassword +type AdminUpdateUserPasswordParams struct { + // in:body + // required:true + Body dtos.AdminUpdateUserPasswordForm `json:"body"` + // in:path + // required:true + UserID int64 `json:"user_id"` +} + +// swagger:parameters adminDeleteUser +type AdminDeleteUserParams struct { + // in:path + // required:true + UserID int64 `json:"user_id"` +} + +// swagger:parameters adminEnableUser +type AdminEnableUserParams struct { + // in:path + // required:true + UserID int64 `json:"user_id"` +} + +// swagger:parameters adminDisableUser +type AdminDisableUserParams struct { + // in:path + // required:true + UserID int64 `json:"user_id"` +} + +// swagger:parameters adminGetUserAuthTokens +type AdminGetUserAuthTokensParams struct { + // in:path + // required:true + UserID int64 `json:"user_id"` +} + +// swagger:parameters adminLogoutUser +type AdminLogoutUserParams struct { + // in:path + // required:true + UserID int64 `json:"user_id"` +} + +// swagger:parameters adminRevokeUserAuthToken +type AdminRevokeUserAuthTokenParams struct { + // in:body + // required:true + Body models.RevokeAuthTokenCmd `json:"body"` + // in:path + // required:true + UserID int64 `json:"user_id"` +} + +// swagger:parameters adminCreateUser +type AdminCreateUserParams struct { + // in:body + // required:true + Body dtos.AdminCreateUserForm `json:"body"` +} + +// swagger:parameters adminUpdateUserPermissions +type AdminUpdateUserPermissionsParams struct { + // in:body + // required:true + Body dtos.AdminUpdateUserPermissionsForm `json:"body"` + // in:path + // required:true + UserID int64 `json:"user_id"` +} + +// swagger:response adminCreateUserResponse +type AdminCreateUserResponseResponse struct { + // in:body + Body models.UserIdDTO `json:"body"` +} + +// swagger:response adminGetUserAuthTokensResponse +type AdminGetUserAuthTokensResponse struct { + // in:body + Body []*models.UserToken `json:"body"` +} diff --git a/pkg/api/alerting.go b/pkg/api/alerting.go index fa46accb629..6f49f6ba820 100644 --- a/pkg/api/alerting.go +++ b/pkg/api/alerting.go @@ -39,6 +39,15 @@ func (hs *HTTPServer) ValidateOrgAlert(c *models.ReqContext) { } } +// swagger:route GET /alerts/states-for-dashboard legacy_alerts getDashboardStates +// +// Get alert states for a dashboard. +// +// Responses: +// Responses: +// 200: getDashboardStatesResponse +// 400: badRequestError +// 500: internalServerError func (hs *HTTPServer) GetAlertStatesForDashboard(c *models.ReqContext) response.Response { dashboardID := c.QueryInt64("dashboardId") @@ -58,7 +67,14 @@ func (hs *HTTPServer) GetAlertStatesForDashboard(c *models.ReqContext) response. return response.JSON(http.StatusOK, query.Result) } -// GET /api/alerts +// swagger:route GET /alerts legacy_alerts getAlerts +// +// Get legacy alerts. +// +// Responses: +// 200: getAlertsResponse +// 401: unauthorisedError +// 500: internalServerError func (hs *HTTPServer) GetAlerts(c *models.ReqContext) response.Response { dashboardQuery := c.Query("dashboardQuery") dashboardTags := c.QueryStrings("dashboardTag") @@ -136,7 +152,16 @@ func (hs *HTTPServer) GetAlerts(c *models.ReqContext) response.Response { return response.JSON(http.StatusOK, query.Result) } -// POST /api/alerts/test +// swagger:route POST /alerts/test legacy_alerts testAlert +// +// Test alert. +// +// Responses: +// 200: testAlertResponse +// 400: badRequestError +// 422: unprocessableEntityError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) AlertTest(c *models.ReqContext) response.Response { dto := dtos.AlertTestCommand{} if err := web.Bind(c.Req, &dto); err != nil { @@ -180,7 +205,17 @@ func (hs *HTTPServer) AlertTest(c *models.ReqContext) response.Response { return response.JSON(http.StatusOK, dtoRes) } -// GET /api/alerts/:id +// swagger:route GET /alerts/{alert_id} legacy_alerts getAlertByID +// +// Get alert by ID. +// +// “evalMatches” data in the response is cached in the db when and only when the state of the alert changes (e.g. transitioning from “ok” to “alerting” state). +// If data from one server triggers the alert first and, before that server is seen leaving alerting state, a second server also enters a state that would trigger the alert, the second server will not be visible in “evalMatches” data. +// +// Responses: +// 200: getAlertResponse +// 401: unauthorisedError +// 500: internalServerError func (hs *HTTPServer) GetAlert(c *models.ReqContext) response.Response { id, err := strconv.ParseInt(web.Params(c.Req)[":alertId"], 10, 64) if err != nil { @@ -206,6 +241,17 @@ func (hs *HTTPServer) GetAlertNotifiers(ngalertEnabled bool) func(*models.ReqCon } } +// swagger:route GET /alert-notifications/lookup legacy_alerts_notification_channels getAlertNotificationLookup +// +// Get all notification channels (lookup) +// +// Returns all notification channels, but with less detailed information. Accessible by any authenticated user and is mainly used by providing alert notification channels in Grafana UI when configuring alert rule. +// +// Responses: +// 200: getAlertNotificationLookupResponse +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) GetAlertNotificationLookup(c *models.ReqContext) response.Response { alertNotifications, err := hs.getAlertNotificationsInternal(c) if err != nil { @@ -221,6 +267,17 @@ func (hs *HTTPServer) GetAlertNotificationLookup(c *models.ReqContext) response. return response.JSON(http.StatusOK, result) } +// swagger:route GET /alert-notifications legacy_alerts_notification_channels getAlertNotificationChannels +// +// Get all notification channels. +// +// Returns all notification channels that the authenticated user has permission to view. +// +// Responses: +// 200: getAlertNotificationChannelsResponse +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) GetAlertNotifications(c *models.ReqContext) response.Response { alertNotifications, err := hs.getAlertNotificationsInternal(c) if err != nil { @@ -246,6 +303,18 @@ func (hs *HTTPServer) getAlertNotificationsInternal(c *models.ReqContext) ([]*mo return query.Result, nil } +// swagger:route GET /alert-notifications/{notification_channel_id} legacy_alerts_notification_channels getAlertNotificationChannelByID +// +// Get notification channel by ID. +// +// Returns the notification channel given the notification channel ID. +// +// Responses: +// 200: getAlertNotificationChannelResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) GetAlertNotificationByID(c *models.ReqContext) response.Response { notificationId, err := strconv.ParseInt(web.Params(c.Req)[":notificationId"], 10, 64) if err != nil { @@ -271,6 +340,18 @@ func (hs *HTTPServer) GetAlertNotificationByID(c *models.ReqContext) response.Re return response.JSON(http.StatusOK, dtos.NewAlertNotification(query.Result)) } +// swagger:route GET /alert-notifications/uid/{notification_channel_uid} legacy_alerts_notification_channels getAlertNotificationChannelByUID +// +// Get notification channel by UID +// +// Returns the notification channel given the notification channel UID. +// +// Responses: +// 200: getAlertNotificationChannelResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) GetAlertNotificationByUID(c *models.ReqContext) response.Response { query := &models.GetAlertNotificationsWithUidQuery{ OrgId: c.OrgId, @@ -292,6 +373,18 @@ func (hs *HTTPServer) GetAlertNotificationByUID(c *models.ReqContext) response.R return response.JSON(http.StatusOK, dtos.NewAlertNotification(query.Result)) } +// swagger:route POST /alert-notifications legacy_alerts_notification_channels createAlertNotificationChannel +// +// Create notification channel. +// +// You can find the full list of [supported notifiers](https://grafana.com/docs/grafana/latest/alerting/old-alerting/notifications/#list-of-supported-notifiers) on the alert notifiers page. +// +// Responses: +// 200: getAlertNotificationChannelResponse +// 401: unauthorisedError +// 403: forbiddenError +// 409: conflictError +// 500: internalServerError func (hs *HTTPServer) CreateAlertNotification(c *models.ReqContext) response.Response { cmd := models.CreateAlertNotificationCommand{} if err := web.Bind(c.Req, &cmd); err != nil { @@ -313,6 +406,18 @@ func (hs *HTTPServer) CreateAlertNotification(c *models.ReqContext) response.Res return response.JSON(http.StatusOK, dtos.NewAlertNotification(cmd.Result)) } +// swagger:route PUT /alert-notifications/{notification_channel_id} legacy_alerts_notification_channels updateAlertNotificationChannel +// +// Update notification channel by ID. +// +// Updates an existing notification channel identified by ID. +// +// Responses: +// 200: getAlertNotificationChannelResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) UpdateAlertNotification(c *models.ReqContext) response.Response { cmd := models.UpdateAlertNotificationCommand{} if err := web.Bind(c.Req, &cmd); err != nil { @@ -348,6 +453,18 @@ func (hs *HTTPServer) UpdateAlertNotification(c *models.ReqContext) response.Res return response.JSON(http.StatusOK, dtos.NewAlertNotification(query.Result)) } +// swagger:route PUT /alert-notifications/uid/{notification_channel_uid} legacy_alerts_notification_channels updateAlertNotificationChannelByUID +// +// Update notification channel by UID. +// +// Updates an existing notification channel identified by uid. +// +// Responses: +// 200: getAlertNotificationChannelResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) UpdateAlertNotificationByUID(c *models.ReqContext) response.Response { cmd := models.UpdateAlertNotificationWithUidCommand{} if err := web.Bind(c.Req, &cmd); err != nil { @@ -436,6 +553,18 @@ func (hs *HTTPServer) fillWithSecureSettingsDataByUID(ctx context.Context, cmd * return nil } +// swagger:route DELETE /alert-notifications/{notification_channel_id} legacy_alerts_notification_channels deleteAlertNotificationChannel +// +// Delete alert notification by ID. +// +// Deletes an existing notification channel identified by ID. +// +// Responses: +// 200: okResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) DeleteAlertNotification(c *models.ReqContext) response.Response { notificationId, err := strconv.ParseInt(web.Params(c.Req)[":notificationId"], 10, 64) if err != nil { @@ -457,6 +586,18 @@ func (hs *HTTPServer) DeleteAlertNotification(c *models.ReqContext) response.Res return response.Success("Notification deleted") } +// swagger:route DELETE /alert-notifications/uid/{notification_channel_uid} legacy_alerts_notification_channels deleteAlertNotificationChannelByUID +// +// Delete alert notification by UID. +// +// Deletes an existing notification channel identified by UID. +// +// Responses: +// 200: deleteAlertNotificationChannelResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) DeleteAlertNotificationByUID(c *models.ReqContext) response.Response { cmd := models.DeleteAlertNotificationWithUidCommand{ OrgId: c.OrgId, @@ -476,7 +617,19 @@ func (hs *HTTPServer) DeleteAlertNotificationByUID(c *models.ReqContext) respons }) } -// POST /api/alert-notifications/test +// swagger:route POST /alert-notifications/test legacy_alerts_notification_channels notificationChannelTest +// +// Test notification channel. +// +// Sends a test notification to the channel. +// +// Responses: +// 200: okResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 412: SMTPNotEnabledError +// 500: internalServerError func (hs *HTTPServer) NotificationTest(c *models.ReqContext) response.Response { dto := dtos.NotificationTestCommand{} if err := web.Bind(c.Req, &dto); err != nil { @@ -506,7 +659,16 @@ func (hs *HTTPServer) NotificationTest(c *models.ReqContext) response.Response { return response.Success("Test notification sent") } -// POST /api/alerts/:alertId/pause +// swagger:route POST /alerts/{alert_id}/pause legacy_alerts pauseAlert +// +// Pause/unpause alert by id. +// +// Responses: +// 200: pauseAlertResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) PauseAlert(legacyAlertingEnabled *bool) func(c *models.ReqContext) response.Response { if legacyAlertingEnabled == nil || !*legacyAlertingEnabled { return func(_ *models.ReqContext) response.Response { @@ -574,7 +736,18 @@ func (hs *HTTPServer) PauseAlert(legacyAlertingEnabled *bool) func(c *models.Req } } -// POST /api/admin/pause-all-alerts +// swagger:route POST /admin/pause-all-alerts admin pauseAllAlerts +// +// Pause/unpause all (legacy) alerts. +// +// Security: +// - basic: +// +// Responses: +// 200: pauseAlertsResponse +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) PauseAllAlerts(legacyAlertingEnabled *bool) func(c *models.ReqContext) response.Response { if legacyAlertingEnabled == nil || !*legacyAlertingEnabled { return func(_ *models.ReqContext) response.Response { @@ -611,3 +784,248 @@ func (hs *HTTPServer) PauseAllAlerts(legacyAlertingEnabled *bool) func(c *models return response.JSON(http.StatusOK, result) } } + +// swagger:parameters pauseAllAlerts +type PauseAllAlertsParams struct { + // in:body + // required:true + Body dtos.PauseAllAlertsCommand `json:"body"` +} + +// swagger:parameters deleteAlertNotificationChannel +type DeleteAlertNotificationChannelParams struct { + // in:path + // required:true + NotificationID int64 `json:"notification_channel_id"` +} + +// swagger:parameters getAlertNotificationChannelByID +type GetAlertNotificationChannelByIDParams struct { + // in:path + // required:true + NotificationID int64 `json:"notification_channel_id"` +} + +// swagger:parameters deleteAlertNotificationChannelByUID +type DeleteAlertNotificationChannelByUIDParams struct { + // in:path + // required:true + NotificationUID string `json:"notification_channel_uid"` +} + +// swagger:parameters getAlertNotificationChannelByUID +type GetAlertNotificationChannelByUIDParams struct { + // in:path + // required:true + NotificationUID string `json:"notification_channel_uid"` +} + +// swagger:parameters notificationChannelTest +type NotificationChannelTestParams struct { + // in:body + // required:true + Body dtos.NotificationTestCommand `json:"body"` +} + +// swagger:parameters createAlertNotificationChannel +type CreateAlertNotificationChannelParams struct { + // in:body + // required:true + Body models.CreateAlertNotificationCommand `json:"body"` +} + +// swagger:parameters updateAlertNotificationChannel +type UpdateAlertNotificationChannelParams struct { + // in:body + // required:true + Body models.UpdateAlertNotificationCommand `json:"body"` + // in:path + // required:true + NotificationID int64 `json:"notification_channel_id"` +} + +// swagger:parameters updateAlertNotificationChannelByUID +type UpdateAlertNotificationChannelByUIDParams struct { + // in:body + // required:true + Body models.UpdateAlertNotificationWithUidCommand `json:"body"` + // in:path + // required:true + NotificationUID string `json:"notification_channel_uid"` +} + +// swagger:parameters getAlertByID +type GetAlertByIDParams struct { + // in:path + // required:true + AlertID string `json:"alert_id"` +} + +// swagger:parameters pauseAlert +type PauseAlertParams struct { + // in:path + // required:true + AlertID string `json:"alert_id"` + // in:body + // required:true + Body dtos.PauseAlertCommand `json:"body"` +} + +// swagger:parameters getAlerts +type GetAlertsParams struct { + // Limit response to alerts in specified dashboard(s). You can specify multiple dashboards. + // in:query + // required:false + DashboardID []string `json:"dashboardId"` + // Limit response to alert for a specified panel on a dashboard. + // in:query + // required:false + PanelID int64 `json:"panelId"` + // Limit response to alerts having a name like this value. + // in:query + // required: false + Query string `json:"query"` + // Return alerts with one or more of the following alert states + // in:query + // required:false + // Description: + // * `all` + // * `no_data` + // * `paused` + // * `alerting` + // * `ok` + // * `pending` + // * `unknown` + // enum: all,no_data,paused,alerting,ok,pending,unknown + State string `json:"state"` + // Limit response to X number of alerts. + // in:query + // required:false + Limit int64 `json:"limit"` + // Limit response to alerts of dashboards in specified folder(s). You can specify multiple folders + // in:query + // required:false + // type array + // collectionFormat: multi + FolderID []string `json:"folderId"` + // Limit response to alerts having a dashboard name like this value./ Limit response to alerts having a dashboard name like this value. + // in:query + // required:false + DashboardQuery string `json:"dashboardQuery"` + // Limit response to alerts of dashboards with specified tags. To do an “AND” filtering with multiple tags, specify the tags parameter multiple times + // in:query + // required:false + // type: array + // collectionFormat: multi + DashboardTag []string `json:"dashboardTag"` +} + +// swagger:parameters testAlert +type TestAlertParams struct { + // in:body + Body dtos.AlertTestCommand `json:"body"` +} + +// swagger:parameters getDashboardStates +type GetDashboardStatesParams struct { + // in:query + // required: true + DashboardID int64 `json:"dashboardId"` +} + +// swagger:response pauseAlertsResponse +type PauseAllAlertsResponse struct { + // in:body + Body struct { + // AlertsAffected is the number of the affected alerts. + // required: true + AlertsAffected int64 `json:"alertsAffected"` + // required: true + Message string `json:"message"` + // Alert result state + // required true + State string `json:"state"` + } `json:"body"` +} + +// swagger:response getAlertNotificationChannelsResponse +type GetAlertNotificationChannelsResponse struct { + // The response message + // in: body + Body []*dtos.AlertNotification `json:"body"` +} + +// swagger:response getAlertNotificationLookupResponse +type LookupAlertNotificationChannelsResponse struct { + // The response message + // in: body + Body []*dtos.AlertNotificationLookup `json:"body"` +} + +// swagger:response getAlertNotificationChannelResponse +type GetAlertNotificationChannelResponse struct { + // The response message + // in: body + Body *dtos.AlertNotification `json:"body"` +} + +// swagger:response deleteAlertNotificationChannelResponse +type DeleteAlertNotificationChannelResponse struct { + // The response message + // in: body + Body struct { + // ID Identifier of the deleted notification channel. + // required: true + // example: 65 + ID int64 `json:"id"` + + // Message Message of the deleted notificatiton channel. + // required: true + Message string `json:"message"` + } `json:"body"` +} + +// swagger:response SMTPNotEnabledError +type SMTPNotEnabledError PreconditionFailedError + +// swagger:response getAlertsResponse +type GetAlertsResponse struct { + // The response message + // in: body + Body []*models.AlertListItemDTO `json:"body"` +} + +// swagger:response getAlertResponse +type GetAlertResponse struct { + // The response message + // in: body + Body *models.Alert `json:"body"` +} + +// swagger:response pauseAlertResponse +type PauseAlertResponse struct { + // in:body + Body struct { + // required: true + AlertID int64 `json:"alertId"` + // required: true + Message string `json:"message"` + // Alert result state + // required true + State string `json:"state"` + } `json:"body"` +} + +// swagger:response testAlertResponse +type TestAlertResponse struct { + // The response message + // in: body + Body *dtos.AlertTestResult `json:"body"` +} + +// swagger:response getDashboardStatesResponse +type GetDashboardStatesResponse struct { + // The response message + // in: body + Body []*models.AlertStateInfoDTO `json:"body"` +} diff --git a/pkg/api/annotations.go b/pkg/api/annotations.go index 5a44ebbc4fa..cf928f7e114 100644 --- a/pkg/api/annotations.go +++ b/pkg/api/annotations.go @@ -18,6 +18,16 @@ import ( "github.com/grafana/grafana/pkg/web" ) +// swagger:route GET /annotations annotations getAnnotations +// +// Find Annotations. +// +// Starting in Grafana v6.4 regions annotations are now returned in one entity that now includes the timeEnd property. +// +// Responses: +// 200: getAnnotationsResponse +// 401: unauthorisedError +// 500: internalServerError func (hs *HTTPServer) GetAnnotations(c *models.ReqContext) response.Response { query := &annotations.ItemQuery{ From: c.QueryInt64("from"), @@ -84,6 +94,20 @@ func (e *AnnotationError) Error() string { return e.message } +// swagger:route POST /annotations annotations postAnnotation +// +// Create Annotation. +// +// Creates an annotation in the Grafana database. The dashboardId and panelId fields are optional. If they are not specified then an organization annotation is created and can be queried in any dashboard that adds the Grafana annotations data source. When creating a region annotation include the timeEnd property. +// The format for `time` and `timeEnd` should be epoch numbers in millisecond resolution. +// The response for this HTTP request is slightly different in versions prior to v6.4. In prior versions you would also get an endId if you where creating a region. But in 6.4 regions are represented using a single event with time and timeEnd properties. +// +// Responses: +// 200: postAnnotationResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) PostAnnotation(c *models.ReqContext) response.Response { cmd := dtos.PostAnnotationsCmd{} if err := web.Bind(c.Req, &cmd); err != nil { @@ -145,6 +169,18 @@ func formatGraphiteAnnotation(what string, data string) string { return text } +// swagger:route POST /annotations/graphite annotations postGraphiteAnnotation +// +// Create Annotation in Graphite format. +// +// Creates an annotation by using Graphite-compatible event format. The `when` and `data` fields are optional. If `when` is not specified then the current time will be used as annotation’s timestamp. The `tags` field can also be in prior to Graphite `0.10.0` format (string with multiple tags being separated by a space). +// +// Responses: +// 200: postAnnotationResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) PostGraphiteAnnotation(c *models.ReqContext) response.Response { cmd := dtos.PostGraphiteAnnotationsCmd{} if err := web.Bind(c.Req, &cmd); err != nil { @@ -200,6 +236,18 @@ func (hs *HTTPServer) PostGraphiteAnnotation(c *models.ReqContext) response.Resp }) } +// swagger:route PUT /annotations/{annotation_id} annotations updateAnnotation +// +// Update Annotation. +// +// Updates all properties of an annotation that matches the specified id. To only update certain property, consider using the Patch Annotation operation. +// +// Responses: +// 200: okResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) UpdateAnnotation(c *models.ReqContext) response.Response { cmd := dtos.UpdateAnnotationsCmd{} if err := web.Bind(c.Req, &cmd); err != nil { @@ -239,6 +287,20 @@ func (hs *HTTPServer) UpdateAnnotation(c *models.ReqContext) response.Response { return response.Success("Annotation updated") } +// swagger:route PATCH /annotations/{annotation_id} annotations patchAnnotation +// +// Patch Annotation +// +// Updates one or more properties of an annotation that matches the specified ID. +// This operation currently supports updating of the `text`, `tags`, `time` and `timeEnd` properties. +// This is available in Grafana 6.0.0-beta2 and above. +// +// Responses: +// 200: okResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) PatchAnnotation(c *models.ReqContext) response.Response { cmd := dtos.PatchAnnotationsCmd{} if err := web.Bind(c.Req, &cmd); err != nil { @@ -293,6 +355,14 @@ func (hs *HTTPServer) PatchAnnotation(c *models.ReqContext) response.Response { return response.Success("Annotation patched") } +// swagger:route POST /annotations/mass-delete annotations massDeleteAnnotations +// +// Delete multiple annotations. +// +// Responses: +// 200: okResponse +// 401: unauthorisedError +// 500: internalServerError func (hs *HTTPServer) MassDeleteAnnotations(c *models.ReqContext) response.Response { cmd := dtos.MassDeleteAnnotationsCmd{} err := web.Bind(c.Req, &cmd) @@ -362,6 +432,14 @@ func (hs *HTTPServer) MassDeleteAnnotations(c *models.ReqContext) response.Respo return response.Success("Annotations deleted") } +// swagger:route GET /annotations/{annotation_id} annotations getAnnotationByID +// +// Get Annotation by Id. +// +// Responses: +// 200: getAnnotationByIDResponse +// 401: unauthorisedError +// 500: internalServerError func (hs *HTTPServer) GetAnnotationByID(c *models.ReqContext) response.Response { annotationID, err := strconv.ParseInt(web.Params(c.Req)[":annotationId"], 10, 64) if err != nil { @@ -382,6 +460,17 @@ func (hs *HTTPServer) GetAnnotationByID(c *models.ReqContext) response.Response return response.JSON(200, annotation) } +// swagger:route DELETE /annotations/{annotation_id} annotations deleteAnnotationByID +// +// Delete Annotation By ID. +// +// Deletes the annotation that matches the specified ID. +// +// Responses: +// 200: okResponse +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) DeleteAnnotationByID(c *models.ReqContext) response.Response { annotationID, err := strconv.ParseInt(web.Params(c.Req)[":annotationId"], 10, 64) if err != nil { @@ -449,6 +538,16 @@ func findAnnotationByID(ctx context.Context, repo annotations.Repository, annota return items[0], nil } +// swagger:route GET /annotations/tags annotations getAnnotationTags +// +// Find Annotations Tags. +// +// Find all the event tags created in the annotations. +// +// Responses: +// 200: getAnnotationTagsResponse +// 401: unauthorisedError +// 500: internalServerError func (hs *HTTPServer) GetAnnotationTags(c *models.ReqContext) response.Response { query := &annotations.TagsQuery{ OrgID: c.OrgId, @@ -545,3 +644,162 @@ func (hs *HTTPServer) canMassDeleteAnnotations(c *models.ReqContext, dashboardID return true, nil } + +// swagger:parameters getAnnotationByID +type GetAnnotationByIDParams struct { + // in:path + // required:true + AnnotationID string `json:"annotation_id"` +} + +// swagger:parameters deleteAnnotationByID +type DeleteAnnotationByIDParams struct { + // in:path + // required:true + AnnotationID string `json:"annotation_id"` +} + +// swagger:parameters getAnnotations +type GetAnnotationsParams struct { + // Find annotations created after specific epoch datetime in milliseconds. + // in:query + // required:false + From int64 `json:"from"` + // Find annotations created before specific epoch datetime in milliseconds. + // in:query + // required:false + To int64 `json:"to"` + // Limit response to annotations created by specific user. + // in:query + // required:false + UserID int64 `json:"userId"` + // Find annotations for a specified alert. + // in:query + // required:false + AlertID int64 `json:"alertId"` + // Find annotations that are scoped to a specific dashboard + // in:query + // required:false + DashboardID int64 `json:"dashboardId"` + // Find annotations that are scoped to a specific dashboard + // in:query + // required:false + DashboardUID string `json:"dashboardUID"` + // Find annotations that are scoped to a specific panel + // in:query + // required:false + PanelID int64 `json:"panelId"` + // Max limit for results returned. + // in:query + // required:false + Limit int64 `json:"limit"` + // Use this to filter organization annotations. Organization annotations are annotations from an annotation data source that are not connected specifically to a dashboard or panel. You can filter by multiple tags. + // in:query + // required:false + // type: array + // collectionFormat: multi + Tags []string `json:"tags"` + // Return alerts or user created annotations + // in:query + // required:false + // Description: + // * `alert` + // * `annotation` + // enum: alert,annotation + Type string `json:"type"` + // Match any or all tags + // in:query + // required:false + MatchAny bool `json:"matchAny"` +} + +// swagger:parameters getAnnotationTags +type GetAnnotationTagsParams struct { + // Tag is a string that you can use to filter tags. + // in:query + // required:false + Tag string `json:"tag"` + // Max limit for results returned. + // in:query + // required:false + // default: 100 + Limit string `json:"limit"` +} + +// swagger:parameters massDeleteAnnotations +type MassDeleteAnnotationsParams struct { + // in:body + // required:true + Body dtos.MassDeleteAnnotationsCmd `json:"body"` +} + +// swagger:parameters postAnnotation +type PostAnnotationParams struct { + // in:body + // required:true + Body dtos.PostAnnotationsCmd `json:"body"` +} + +// swagger:parameters postGraphiteAnnotation +type PostGraphiteAnnotationParams struct { + // in:body + // required:true + Body dtos.PostGraphiteAnnotationsCmd `json:"body"` +} + +// swagger:parameters updateAnnotation +type UpdateAnnotationParams struct { + // in:path + // required:true + AnnotationID string `json:"annotation_id"` + // in:body + // required:true + Body dtos.UpdateAnnotationsCmd `json:"body"` +} + +// swagger:parameters patchAnnotation +type PatchAnnotationParams struct { + // in:path + // required:true + AnnotationID string `json:"annotation_id"` + // in:body + // required:true + Body dtos.PatchAnnotationsCmd `json:"body"` +} + +// swagger:response getAnnotationsResponse +type GetAnnotationsResponse struct { + // The response message + // in: body + Body []*annotations.ItemDTO `json:"body"` +} + +// swagger:response getAnnotationByIDResponse +type GetAnnotationByIDResponse struct { + // The response message + // in: body + Body *annotations.ItemDTO `json:"body"` +} + +// swagger:response postAnnotationResponse +type PostAnnotationResponse struct { + // The response message + // in: body + Body struct { + // ID Identifier of the created annotation. + // required: true + // example: 65 + ID int64 `json:"id"` + + // Message Message of the created annotation. + // required: true + Message string `json:"message"` + } `json:"body"` +} + +// swagger:response getAnnotationTagsResponse +type GetAnnotationTagsResponse struct { + // The response message + // in: body + Body annotations.GetAnnotationTagsResponse `json:"body"` +} diff --git a/pkg/api/api.go b/pkg/api/api.go index 58789b610ba..35fa45bd7ef 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -1,4 +1,33 @@ -// Package api contains API logic. +// Package api Grafana HTTP API. +// +// The Grafana backend exposes an HTTP API, the same API is used by the frontend to do +// everything from saving dashboards, creating users and updating data sources. +// +// Schemes: http, https +// BasePath: /api +// Version: 0.0.1 +// License: GNU Affero General Public License v3.0 https://www.gnu.org/licenses/agpl-3.0.en.html +// Contact: Grafana Labs https://grafana.com +// +// Consumes: +// - application/json +// +// Produces: +// - application/json +// +// Security: +// - basic: +// - api_key: +// +// SecurityDefinitions: +// basic: +// type: basic +// api_key: +// type: apiKey +// name: Authorization +// in: header +// +// swagger:meta package api import ( diff --git a/pkg/api/apikey.go b/pkg/api/apikey.go index c1347eef115..675fc837f57 100644 --- a/pkg/api/apikey.go +++ b/pkg/api/apikey.go @@ -13,7 +13,18 @@ import ( "github.com/grafana/grafana/pkg/web" ) -// GetAPIKeys returns a list of API keys +// swagger:route GET /auth/keys api_keys getAPIkeys +// +// Get auth keys. +// +// Will return auth keys. +// +// Responses: +// 200: getAPIkeyResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) GetAPIKeys(c *models.ReqContext) response.Response { query := models.GetApiKeysQuery{OrgId: c.OrgId, User: c.SignedInUser, IncludeExpired: c.QueryBool("includeExpired")} @@ -48,7 +59,16 @@ func (hs *HTTPServer) GetAPIKeys(c *models.ReqContext) response.Response { return response.JSON(http.StatusOK, result) } -// DeleteAPIKey deletes an API key +// swagger:route DELETE /auth/keys/{id} api_keys deleteAPIkey +// +// Delete API key. +// +// Responses: +// 200: okResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) DeleteAPIKey(c *models.ReqContext) response.Response { id, err := strconv.ParseInt(web.Params(c.Req)[":id"], 10, 64) if err != nil { @@ -70,7 +90,19 @@ func (hs *HTTPServer) DeleteAPIKey(c *models.ReqContext) response.Response { return response.Success("API key deleted") } -// AddAPIKey adds an API key +// swagger:route POST /auth/keys api_keys addAPIkey +// +// Creates an API key. +// +// Will return details of the created API key +// +// Responses: +// 200: postAPIkeyResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 409: conflictError +// 500: internalServerError func (hs *HTTPServer) AddAPIKey(c *models.ReqContext) response.Response { cmd := models.AddApiKeyCommand{} if err := web.Bind(c.Req, &cmd); err != nil { @@ -118,3 +150,40 @@ func (hs *HTTPServer) AddAPIKey(c *models.ReqContext) response.Response { return response.JSON(http.StatusOK, result) } + +// swagger:parameters getAPIkeys +type GetAPIkeysParams struct { + // Show expired keys + // in:query + // required:false + // default:false + IncludeExpired bool `json:"includeExpired"` +} + +// swagger:parameters addAPIkey +type AddAPIkeyParams struct { + // in:body + // required:true + Body models.AddApiKeyCommand +} + +// swagger:parameters deleteAPIkey +type DeleteAPIkeyParams struct { + // in:path + // required:true + ID int64 `json:"id"` +} + +// swagger:response getAPIkeyResponse +type GetAPIkeyResponse struct { + // The response message + // in: body + Body []*dtos.ApiKeyDTO `json:"body"` +} + +// swagger:response postAPIkeyResponse +type PostAPIkeyResponse struct { + // The response message + // in: body + Body dtos.NewApiKeyResult `json:"body"` +} diff --git a/pkg/api/dashboard.go b/pkg/api/dashboard.go index 0be4bc7e377..c7f3b285895 100644 --- a/pkg/api/dashboard.go +++ b/pkg/api/dashboard.go @@ -53,6 +53,14 @@ func dashboardGuardianResponse(err error) response.Response { return response.Error(403, "Access denied to this dashboard", nil) } +// swagger:route POST /dashboards/trim dashboards trimDashboard +// +// Trim defaults from dashboard. +// +// Responses: +// 200: trimDashboardResponse +// 401: unauthorisedError +// 500: internalServerError func (hs *HTTPServer) TrimDashboard(c *models.ReqContext) response.Response { cmd := models.TrimDashboardCommand{} if err := web.Bind(c.Req, &cmd); err != nil { @@ -71,6 +79,18 @@ func (hs *HTTPServer) TrimDashboard(c *models.ReqContext) response.Response { return response.JSON(http.StatusOK, dto) } +// swagger:route GET /dashboards/uid/{uid} dashboards getDashboardByUID +// +// Get dashboard by uid. +// +// Will return the dashboard given the dashboard unique identifier (uid). +// +// Responses: +// 200: dashboardResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) GetDashboard(c *models.ReqContext) response.Response { uid := web.Params(c.Req)[":uid"] dash, rsp := hs.getDashboardHelper(c.Req.Context(), c.OrgId, 0, uid) @@ -255,6 +275,18 @@ func (hs *HTTPServer) getDashboardHelper(ctx context.Context, orgID int64, id in return query.Result, nil } +// DeleteDashboardByUID swagger:route DELETE /dashboards/uid/{uid} dashboards deleteDashboardByUID +// +// Delete dashboard by uid. +// +// Will delete the dashboard given the specified unique identifier (uid). +// +// Responses: +// 200: deleteDashboardResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) DeleteDashboardByUID(c *models.ReqContext) response.Response { return hs.deleteDashboard(c) } @@ -308,6 +340,21 @@ func (hs *HTTPServer) deleteDashboard(c *models.ReqContext) response.Response { }) } +// swagger:route POST /dashboards/db dashboards postDashboard +// +// Create / Update dashboard +// +// Creates a new dashboard or updates an existing dashboard. +// +// Responses: +// 200: postDashboardResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 412: preconditionFailedError +// 422: unprocessableEntityError +// 500: internalServerError func (hs *HTTPServer) PostDashboard(c *models.ReqContext) response.Response { cmd := models.SaveDashboardCommand{} if err := web.Bind(c.Req, &cmd); err != nil { @@ -456,7 +503,14 @@ func (hs *HTTPServer) postDashboard(c *models.ReqContext, cmd models.SaveDashboa }) } -// GetHomeDashboard returns the home dashboard. +// swagger:route GET /dashboards/home dashboards getHomeDashboard +// +// Get home dashboard. +// +// Responses: +// 200: getHomeDashboardResponse +// 401: unauthorisedError +// 500: internalServerError func (hs *HTTPServer) GetHomeDashboard(c *models.ReqContext) response.Response { prefsQuery := pref.GetPreferenceWithDefaultsQuery{OrgID: c.OrgId, UserID: c.SignedInUser.UserId, Teams: c.Teams} homePage := hs.Cfg.HomePage @@ -542,7 +596,31 @@ func (hs *HTTPServer) addGettingStartedPanelToHomeDashboard(c *models.ReqContext dash.Set("panels", panels) } -// GetDashboardVersions returns all dashboard versions as JSON +// swagger:route GET /dashboards/id/{DashboardID}/versions dashboard_versions getDashboardVersionsByID +// +// Gets all existing versions for the dashboard. +// +// Please refer to [updated API](#/dashboard_versions/getDashboardVersionsByUID) instead +// +// Deprecated: true +// +// Responses: +// 200: dashboardVersionsResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError + +// swagger:route GET /dashboards/uid/{uid}/versions dashboard_versions getDashboardVersionsByUID +// +// Gets all existing versions for the dashboard using UID. +// +// Responses: +// 200: dashboardVersionsResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) GetDashboardVersions(c *models.ReqContext) response.Response { var dashID int64 @@ -601,7 +679,31 @@ func (hs *HTTPServer) GetDashboardVersions(c *models.ReqContext) response.Respon return response.JSON(http.StatusOK, res) } -// GetDashboardVersion returns the dashboard version with the given ID. +// swagger:route GET /dashboards/id/{DashboardID}/versions/{DashboardVersionID} dashboard_versions getDashboardVersionByID +// +// Get a specific dashboard version. +// +// Please refer to [updated API](#/dashboard_versions/getDashboardVersionByUID) instead +// +// Deprecated: true +// +// Responses: +// 200: dashboardVersionResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError + +// swagger:route GET /dashboards/uid/{uid}/versions/{DashboardVersionID} dashboard_versions getDashboardVersionByUID +// +// Get a specific dashboard version using UID. +// +// Responses: +// 200: dashboardVersionResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) GetDashboardVersion(c *models.ReqContext) response.Response { var dashID int64 @@ -662,7 +764,19 @@ func (hs *HTTPServer) GetDashboardVersion(c *models.ReqContext) response.Respons return response.JSON(http.StatusOK, dashVersionMeta) } -// POST /api/dashboards/calculate-diff performs diffs on two dashboards +// swagger:route POST /dashboards/calculate-diff dashboards calculateDashboardDiff +// +// Perform diff on two dashboards. +// +// Produces: +// - application/json +// - text/html +// +// Responses: +// 200: calculateDashboardDiffResponse +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) CalculateDashboardDiff(c *models.ReqContext) response.Response { apiOptions := dtos.CalculateDiffOptions{} if err := web.Bind(c.Req, &apiOptions); err != nil { @@ -742,7 +856,31 @@ func (hs *HTTPServer) CalculateDashboardDiff(c *models.ReqContext) response.Resp return response.Respond(http.StatusOK, result.Delta).SetHeader("Content-Type", "text/html") } -// RestoreDashboardVersion restores a dashboard to the given version. +// swagger:route POST /dashboards/id/{DashboardID}/restore dashboard_versions restoreDashboardVersionByID +// +// Restore a dashboard to a given dashboard version. +// +// Please refer to [updated API](#/dashboard_versions/restoreDashboardVersionByUID) instead +// +// Deprecated: true +// +// Responses: +// 200: postDashboardResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError + +// swagger:route POST /dashboards/uid/{uid}/restore dashboard_versions restoreDashboardVersionByUID +// +// Restore a dashboard to a given dashboard version using UID. +// +// Responses: +// 200: postDashboardResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) RestoreDashboardVersion(c *models.ReqContext) response.Response { var dashID int64 @@ -793,6 +931,14 @@ func (hs *HTTPServer) RestoreDashboardVersion(c *models.ReqContext) response.Res return hs.postDashboard(c, saveCmd) } +// swagger:route GET /dashboards/tags dashboards getDashboardTags +// +// Get all dashboards tags of an organisation. +// +// Responses: +// 200: getDashboardsTagsResponse +// 401: unauthorisedError +// 500: internalServerError func (hs *HTTPServer) GetDashboardTags(c *models.ReqContext) { query := models.GetDashboardTagsQuery{OrgId: c.OrgId} err := hs.DashboardService.GetDashboardTags(c.Req.Context(), &query) @@ -824,3 +970,230 @@ func (hs *HTTPServer) GetDashboardUIDs(c *models.ReqContext) { } c.JSON(http.StatusOK, uids) } + +// swagger:parameters renderReportPDF +type RenderReportPDFParams struct { + // in:path + DashboardID int64 +} + +// swagger:parameters restoreDashboardVersionByID +type RestoreDashboardVersionByIDParams struct { + // in:body + // required:true + Body dtos.RestoreDashboardVersionCommand + // in:path + DashboardID int64 +} + +// swagger:parameters getDashboardVersionsByID +type GetDashboardVersionsByIDParams struct { + // in:path + DashboardID int64 +} + +// swagger:parameters getDashboardVersionsByUID +type GetDashboardVersionsByUIDParams struct { + // in:path + // required:true + UID string `json:"uid"` +} + +// swagger:parameters restoreDashboardVersionByUID +type RestoreDashboardVersionByUIDParams struct { + // in:body + // required:true + Body dtos.RestoreDashboardVersionCommand + // in:path + // required:true + UID string `json:"uid"` +} + +// swagger:parameters getDashboardVersionByID +type GetDashboardVersionByIDParams struct { + // in:path + DashboardID int64 + // in:path + DashboardVersionID int64 +} + +// swagger:parameters getDashboardVersionByUID +type GetDashboardVersionByUIDParams struct { + // in:path + DashboardVersionID int64 + // in:path + // required:true + UID string `json:"uid"` +} + +// swagger:parameters getDashboardVersions getDashboardVersionsByUID +type GetDashboardVersionsParams struct { + // Maximum number of results to return + // in:query + // required:false + // default:0 + Limit int `json:"limit"` + + // Version to start from when returning queries + // in:query + // required:false + // default:0 + Start int `json:"start"` +} + +// swagger:parameters getDashboardByUID +type GetDashboardByUIDParams struct { + // in:path + // required:true + UID string `json:"uid"` +} + +// swagger:parameters deleteDashboardByUID +type DeleteDashboardByUIDParams struct { + // in:path + // required:true + UID string `json:"uid"` +} + +// swagger:parameters postDashboard +type PostDashboardParams struct { + // in:body + // required:true + Body models.SaveDashboardCommand +} + +// swagger:parameters calculateDashboardDiff +type CalcDashboardDiffParams struct { + // in:body + // required:true + Body struct { + Base dtos.CalculateDiffTarget `json:"base" binding:"Required"` + New dtos.CalculateDiffTarget `json:"new" binding:"Required"` + // The type of diff to return + // Description: + // * `basic` + // * `json` + // Enum: basic,json + DiffType string `json:"diffType" binding:"Required"` + } +} + +// swagger:parameters trimDashboard +type TrimDashboardParams struct { + // in:body + // required:true + Body models.TrimDashboardCommand +} + +// swagger:response dashboardResponse +type DashboardResponse struct { + // The response message + // in: body + Body dtos.DashboardFullWithMeta `json:"body"` +} + +// swagger:response deleteDashboardResponse +type DeleteDashboardResponse struct { + // The response message + // in: body + Body struct { + // ID Identifier of the deleted dashboard. + // required: true + // example: 65 + ID int64 `json:"id"` + + // Title Title of the deleted dashboard. + // required: true + // example: My Dashboard + Title string `json:"title"` + + // Message Message of the deleted dashboard. + // required: true + // example: Dashboard My Dashboard deleted + Message string `json:"message"` + } `json:"body"` +} + +// swagger:response postDashboardResponse +type PostDashboardResponse struct { + // in: body + Body struct { + // Status status of the response. + // required: true + // example: success + Status string `json:"status"` + + // Slug The slug of the dashboard. + // required: true + // example: my-dashboard + Slug string `json:"title"` + + // Version The version of the dashboard. + // required: true + // example: 2 + Verion int64 `json:"version"` + + // ID The unique identifier (id) of the created/updated dashboard. + // required: true + // example: 1 + ID string `json:"id"` + + // UID The unique identifier (uid) of the created/updated dashboard. + // required: true + // example: nHz3SXiiz + UID string `json:"uid"` + + // URL The relative URL for accessing the created/updated dashboard. + // required: true + // example: /d/nHz3SXiiz/my-dashboard + URL string `json:"url"` + } `json:"body"` +} + +// swagger:response calculateDashboardDiffResponse +type CalculateDashboardDiffResponse struct { + // in: body + Body []byte `json:"body"` +} + +// swagger:response trimDashboardResponse +type TrimDashboardResponse struct { + // in: body + Body dtos.TrimDashboardFullWithMeta `json:"body"` +} + +// swagger:response getHomeDashboardResponse +type GetHomeDashboardResponse struct { + // in: body + Body GetHomeDashboardResponseBody `json:"body"` +} + +// swagger:response getDashboardsTagsResponse +type DashboardsTagsResponse struct { + // in: body + Body []*models.DashboardTagCloudItem `json:"body"` +} + +// Get home dashboard response. +// swagger:model GetHomeDashboardResponse +type GetHomeDashboardResponseBody struct { + // swagger:allOf + // required: false + dtos.DashboardFullWithMeta + + // swagger:allOf + // required: false + dtos.DashboardRedirect +} + +// swagger:response dashboardVersionsResponse +type DashboardVersionsResponse struct { + // in: body + Body []*dashver.DashboardVersionDTO `json:"body"` +} + +// swagger:response dashboardVersionResponse +type DashboardVersionResponse struct { + // in: body + Body *dashver.DashboardVersionMeta `json:"body"` +} diff --git a/pkg/api/dashboard_permission.go b/pkg/api/dashboard_permission.go index ea0bd168700..ffa21ed9f53 100644 --- a/pkg/api/dashboard_permission.go +++ b/pkg/api/dashboard_permission.go @@ -15,6 +15,31 @@ import ( "github.com/grafana/grafana/pkg/web" ) +// swagger:route GET /dashboards/uid/{uid}/permissions dashboard_permissions getDashboardPermissionsListByUID +// +// Gets all existing permissions for the given dashboard. +// +// Responses: +// 200: getDashboardPermissionsListResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError + +// swagger:route GET /dashboards/id/{DashboardID}/permissions dashboard_permissions getDashboardPermissionsListByID +// +// Gets all existing permissions for the given dashboard. +// +// Please refer to [updated API](#/dashboard_permissions/getDashboardPermissionsListByUID) instead +// +// Deprecated: true +// +// Responses: +// 200: getDashboardPermissionsListResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) GetDashboardPermissionList(c *models.ReqContext) response.Response { var dashID int64 var err error @@ -67,6 +92,37 @@ func (hs *HTTPServer) GetDashboardPermissionList(c *models.ReqContext) response. return response.JSON(http.StatusOK, filteredACLs) } +// swagger:route POST /dashboards/uid/{uid}/permissions dashboard_permissions updateDashboardPermissionsByUID +// +// Updates permissions for a dashboard. +// +// This operation will remove existing permissions if they’re not included in the request. +// +// Responses: +// 200: okResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError + +// swagger:route POST /dashboards/id/{DashboardID}/permissions dashboard_permissions updateDashboardPermissionsByID +// +// Updates permissions for a dashboard. +// +// Please refer to [updated API](#/dashboard_permissions/updateDashboardPermissionsByUID) instead +// +// This operation will remove existing permissions if they’re not included in the request. +// +// Deprecated: true +// +// Responses: +// 200: okResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) UpdateDashboardPermissions(c *models.ReqContext) response.Response { var dashID int64 var err error @@ -228,3 +284,42 @@ func validatePermissionsUpdate(apiCmd dtos.UpdateDashboardACLCommand) error { } return nil } + +// swagger:parameters getDashboardPermissionsListByUID +type GetDashboardPermissionsListByUIDParams struct { + // in:path + // required:true + UID string `json:"uid"` +} + +// swagger:parameters getDashboardPermissionsListByID +type GetDashboardPermissionsListByIDParams struct { + // in:path + DashboardID int64 +} + +// swagger:parameters updateDashboardPermissionsByID +type UpdateDashboardPermissionsByIDParams struct { + // in:body + // required:true + Body dtos.UpdateDashboardACLCommand + // in:path + DashboardID int64 +} + +// swagger:parameters updateDashboardPermissionsByUID +type UpdateDashboardPermissionsByUIDParams struct { + // in:body + // required:true + Body dtos.UpdateDashboardACLCommand + // in:path + // required:true + // description: The dashboard UID + UID string `json:"uid"` +} + +// swagger:response getDashboardPermissionsListResponse +type GetDashboardPermissionsResponse struct { + // in: body + Body []*models.DashboardACLInfoDTO `json:"body"` +} diff --git a/pkg/api/dashboard_snapshot.go b/pkg/api/dashboard_snapshot.go index 2c2ae051586..04e1f35c32f 100644 --- a/pkg/api/dashboard_snapshot.go +++ b/pkg/api/dashboard_snapshot.go @@ -26,6 +26,13 @@ var client = &http.Client{ Transport: &http.Transport{Proxy: http.ProxyFromEnvironment}, } +// swagger:route GET /snapshot/shared-options snapshots getSharingOptions +// +// Get snapshot sharing settings. +// +// Responses: +// 200: getSharingOptionsResponse +// 401: unauthorisedError func GetSharingOptions(c *models.ReqContext) { c.JSON(http.StatusOK, util.DynMap{ "externalSnapshotURL": setting.ExternalSnapshotUrl, @@ -77,7 +84,17 @@ func createExternalDashboardSnapshot(cmd dashboardsnapshots.CreateDashboardSnaps return &createSnapshotResponse, nil } -// POST /api/snapshots +// swagger:route POST /snapshots snapshots createDashboardSnapshot +// +// When creating a snapshot using the API, you have to provide the full dashboard payload including the snapshot data. This endpoint is designed for the Grafana UI. +// +// Snapshot public mode should be enabled or authentication is required. +// +// Responses: +// 200: createDashboardSnapshotResponse +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) CreateDashboardSnapshot(c *models.ReqContext) response.Response { cmd := dashboardsnapshots.CreateDashboardSnapshotCommand{} if err := web.Bind(c.Req, &cmd); err != nil { @@ -152,6 +169,14 @@ func (hs *HTTPServer) CreateDashboardSnapshot(c *models.ReqContext) response.Res } // GET /api/snapshots/:key +// swagger:route GET /snapshots/{key} snapshots getDashboardSnapshot +// +// Get Snapshot by Key. +// +// Responses: +// 200: getDashboardSnapshotResponse +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) GetDashboardSnapshot(c *models.ReqContext) response.Response { key := web.Params(c.Req)[":key"] if len(key) == 0 { @@ -219,7 +244,18 @@ func deleteExternalDashboardSnapshot(externalUrl string) error { return fmt.Errorf("unexpected response when deleting external snapshot, status code: %d", response.StatusCode) } -// GET /api/snapshots-delete/:deleteKey +// swagger:route GET /snapshots-delete/{deleteKey} snapshots deleteDashboardSnapshotByDeleteKey +// +// Delete Snapshot by deleteKey. +// +// Snapshot public mode should be enabled or authentication is required. +// +// Responses: +// 200: okResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) DeleteDashboardSnapshotByDeleteKey(c *models.ReqContext) response.Response { key := web.Params(c.Req)[":deleteKey"] if len(key) == 0 { @@ -251,7 +287,15 @@ func (hs *HTTPServer) DeleteDashboardSnapshotByDeleteKey(c *models.ReqContext) r }) } -// DELETE /api/snapshots/:key +// swagger:route DELETE /snapshots/{key} snapshots deleteDashboardSnapshot +// +// Delete Snapshot by Key. +// +// Responses: +// 200: okResponse +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) DeleteDashboardSnapshot(c *models.ReqContext) response.Response { key := web.Params(c.Req)[":key"] if len(key) == 0 { @@ -304,7 +348,13 @@ func (hs *HTTPServer) DeleteDashboardSnapshot(c *models.ReqContext) response.Res }) } -// GET /api/dashboard/snapshots +// swagger:route GET /dashboard/snapshots snapshots searchDashboardSnapshots +// +// List snapshots. +// +// Responses: +// 200: searchDashboardSnapshotsResponse +// 500: internalServerError func (hs *HTTPServer) SearchDashboardSnapshots(c *models.ReqContext) response.Response { query := c.Query("query") limit := c.QueryInt("limit") @@ -343,3 +393,73 @@ func (hs *HTTPServer) SearchDashboardSnapshots(c *models.ReqContext) response.Re return response.JSON(http.StatusOK, dtos) } + +// swagger:parameters createDashboardSnapshot +type CreateSnapshotParams struct { + // in:body + // required:true + Body dashboardsnapshots.CreateDashboardSnapshotCommand `json:"body"` +} + +// swagger:parameters searchDashboardSnapshots +type GetSnapshotsParams struct { + // Search Query + // in:query + Query string `json:"query"` + // Limit the number of returned results + // in:query + // default:1000 + Limit int64 `json:"limit"` +} + +// swagger:parameters getDashboardSnapshot +type GetDashboardSnapshotParams struct { + // in:path + Key string `json:"key"` +} + +// swagger:parameters deleteDashboardSnapshot +type DeleteDashboardSnapshotParams struct { + // in:path + Key string `json:"key"` +} + +// swagger:parameters deleteDashboardSnapshotByDeleteKey +type DeleteSnapshotByDeleteKeyParams struct { + // in:path + DeleteKey string `json:"deleteKey"` +} + +// swagger:response createDashboardSnapshotResponse +type CreateSnapshotResponse struct { + // in:body + Body struct { + // Unique key + Key string `json:"key"` + // Unique key used to delete the snapshot. It is different from the key so that only the creator can delete the snapshot. + DeleteKey string `json:"deleteKey"` + URL string `json:"url"` + DeleteUrl string `json:"deleteUrl"` + // Snapshot id + ID int64 `json:"id"` + } `json:"body"` +} + +// swagger:response searchDashboardSnapshotsResponse +type SearchDashboardSnapshotsResponse struct { + // in:body + Body []*dashboardsnapshots.DashboardSnapshotDTO `json:"body"` +} + +// swagger:response getDashboardSnapshotResponse +type GetDashboardSnapshotResponse DashboardResponse + +// swagger:response getSharingOptionsResponse +type GetSharingOptionsResponse struct { + // in:body + Body struct { + ExternalSnapshotURL string `json:"externalSnapshotURL"` + ExternalSnapshotName string `json:"externalSnapshotName"` + ExternalEnabled bool `json:"externalEnabled"` + } `json:"body"` +} diff --git a/pkg/api/dataproxy.go b/pkg/api/dataproxy.go index 220f3f31b7a..09edcfd379a 100644 --- a/pkg/api/dataproxy.go +++ b/pkg/api/dataproxy.go @@ -2,10 +2,175 @@ package api import "github.com/grafana/grafana/pkg/models" +// swagger:route GET /datasources/proxy/{id}/{datasource_proxy_route} datasources datasourceProxyGETcalls +// +// Data source proxy GET calls. +// +// Proxies all calls to the actual data source. +// +// Please refer to [updated API](#/datasources/datasourceProxyGETByUIDcalls) instead +// +// Deprecated: true +// +// Responses: +// 200: +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError + +// swagger:route POST /datasources/proxy/{id}/{datasource_proxy_route} datasources datasourceProxyPOSTcalls +// +// Data source proxy POST calls. +// +// Proxies all calls to the actual data source. The data source should support POST methods for the specific path and role as defined +// +// Please refer to [updated API](#/datasources/datasourceProxyPOSTByUIDcalls) instead +// +// Deprecated: true +// +// Responses: +// 201: +// 202: +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError + +// swagger:route DELETE /datasources/proxy/{id}/{datasource_proxy_route} datasources datasourceProxyDELETEcalls +// +// Data source proxy DELETE calls. +// +// Proxies all calls to the actual data source. +// +// Please refer to [updated API](#/datasources/datasourceProxyDELETEByUIDcalls) instead +// +// Deprecated: true +// +// Responses: +// 202: +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) ProxyDataSourceRequest(c *models.ReqContext) { hs.DataProxy.ProxyDataSourceRequest(c) } +// swagger:route GET /datasources/proxy/uid/{uid}/{datasource_proxy_route} datasources datasourceProxyGETByUIDcalls +// +// Data source proxy GET calls. +// +// Proxies all calls to the actual data source. +// +// Responses: +// 200: +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError + +// swagger:route POST /datasources/proxy/uid/{uid}/{datasource_proxy_route} datasources datasourceProxyPOSTByUIDcalls +// +// Data source proxy POST calls. +// +// Proxies all calls to the actual data source. The data source should support POST methods for the specific path and role as defined +// +// Responses: +// 201: +// 202: +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError + +// swagger:route DELETE /datasources/proxy/uid/{uid}/{datasource_proxy_route} datasources datasourceProxyDELETEByUIDcalls +// +// Data source proxy DELETE calls. +// +// Proxies all calls to the actual data source. +// +// Responses: +// 202: +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) ProxyDataSourceRequestWithUID(c *models.ReqContext) { hs.DataProxy.ProxyDatasourceRequestWithUID(c, "") } + +// swagger:parameters datasourceProxyDELETEcalls +type DatasourceProxyDELETEcallsParams struct { + // in:path + // required:true + DatasourceID string `json:"id"` +} + +// swagger:parameters datasourceProxyDELETEByUIDcalls +type DatasourceProxyDELETEByUIDcallsParams struct { + // in:path + // required:true + DatasourceUID string `json:"uid"` +} + +// swagger:parameters datasourceProxyGETcalls +type DatasourceProxyGETcallsParams struct { + // in:path + // required:true + DatasourceProxyRoute string `json:"datasource_proxy_route"` + // in:path + // required:true + DatasourceID string `json:"id"` +} + +// swagger:parameters datasourceProxyGETByUIDcalls +type DatasourceProxyGETByUIDcallsParams struct { + // in:path + // required:true + DatasourceProxyRoute string `json:"datasource_proxy_route"` + // in:path + // required:true + DatasourceUID string `json:"uid"` +} + +// swagger:parameters datasourceProxyDELETEcalls +// swagger:parameters datasourceProxyDELETEByUIDcalls +// swagger:parameters callDatasourceResourceWithUID callDatasourceResourceByID +type DatasourceProxyRouteParam struct { + // in:path + // required:true + DatasourceProxyRoute string `json:"datasource_proxy_route"` +} + +// swagger:parameters datasourceProxyPOSTcalls +type DatasourceProxyPOSTcallsParams struct { + // in:body + // required:true + DatasourceProxyParam interface{} + // in:path + // required:true + DatasourceProxyRoute string `json:"datasource_proxy_route"` + // in:path + // required:true + DatasourceID string `json:"id"` +} + +// swagger:parameters datasourceProxyPOSTByUIDcalls +type DatasourceProxyPOSTByUIDcallsParams struct { + // in:body + // required:true + DatasourceProxyParam interface{} + // in:path + // required:true + DatasourceProxyRoute string `json:"datasource_proxy_route"` + // in:path + // required:true + DatasourceUID string `json:"uid"` +} diff --git a/pkg/api/datasources.go b/pkg/api/datasources.go index ef075b4b200..8acd522c85c 100644 --- a/pkg/api/datasources.go +++ b/pkg/api/datasources.go @@ -27,6 +27,18 @@ import ( var datasourcesLogger = log.New("datasources") var secretsPluginError datasources.ErrDatasourceSecretsPluginUserFriendly +// swagger:route GET /datasources datasources getDataSources +// +// Get all data sources. +// +// If you are running Grafana Enterprise and have Fine-grained access control enabled +// you need to have a permission with action: `datasources:read` and scope: `datasources:*`. +// +// Responses: +// 200: getDataSourcesResponse +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) GetDataSources(c *models.ReqContext) response.Response { query := datasources.GetDataSourcesQuery{OrgId: c.OrgId, DataSourceLimit: hs.Cfg.DataSourceLimit} @@ -73,7 +85,24 @@ func (hs *HTTPServer) GetDataSources(c *models.ReqContext) response.Response { return response.JSON(http.StatusOK, &result) } -// GET /api/datasources/:id +// swagger:route GET /datasources/{id} datasources getDataSourceByID +// +// Get a single data source by Id. +// +// If you are running Grafana Enterprise and have Fine-grained access control enabled +// you need to have a permission with action: `datasources:read` and scopes: `datasources:*`, `datasources:id:*` and `datasources:id:1` (single data source). +// +// Please refer to [updated API](#/datasources/getDataSourceByUID) instead +// +// Deprecated: true +// +// Responses: +// 200: getDataSourceResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) GetDataSourceById(c *models.ReqContext) response.Response { id, err := strconv.ParseInt(web.Params(c.Req)[":id"], 10, 64) if err != nil { @@ -102,7 +131,23 @@ func (hs *HTTPServer) GetDataSourceById(c *models.ReqContext) response.Response return response.JSON(http.StatusOK, &dto) } -// DELETE /api/datasources/:id +// swagger:route DELETE /datasources/{id} datasources deleteDataSourceByID +// +// Delete an existing data source by id. +// +// If you are running Grafana Enterprise and have Fine-grained access control enabled +// you need to have a permission with action: `datasources:delete` and scopes: `datasources:*`, `datasources:id:*` and `datasources:id:1` (single data source). +// +// Please refer to [updated API](#/datasources/deleteDataSourceByUID) instead +// +// Deprecated: true +// +// Responses: +// 200: okResponse +// 401: unauthorisedError +// 404: notFoundError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) DeleteDataSourceById(c *models.ReqContext) response.Response { id, err := strconv.ParseInt(web.Params(c.Req)[":id"], 10, 64) if err != nil { @@ -140,7 +185,20 @@ func (hs *HTTPServer) DeleteDataSourceById(c *models.ReqContext) response.Respon return response.Success("Data source deleted") } -// GET /api/datasources/uid/:uid +// swagger:route GET /datasources/uid/{uid} datasources getDataSourceByUID +// +// Get a single data source by UID. +// +// If you are running Grafana Enterprise and have Fine-grained access control enabled +// you need to have a permission with action: `datasources:read` and scopes: `datasources:*`, `datasources:uid:*` and `datasources:uid:kLtEtcRGk` (single data source). +// +// Responses: +// 200: getDataSourceResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) GetDataSourceByUID(c *models.ReqContext) response.Response { ds, err := hs.getRawDataSourceByUID(c.Req.Context(), web.Params(c.Req)[":uid"], c.OrgId) @@ -159,7 +217,19 @@ func (hs *HTTPServer) GetDataSourceByUID(c *models.ReqContext) response.Response return response.JSON(http.StatusOK, &dto) } -// DELETE /api/datasources/uid/:uid +// swagger:route DELETE /datasources/uid/{uid} datasources deleteDataSourceByUID +// +// Delete an existing data source by UID. +// +// If you are running Grafana Enterprise and have Fine-grained access control enabled +// you need to have a permission with action: `datasources:delete` and scopes: `datasources:*`, `datasources:uid:*` and `datasources:uid:kLtEtcRGk` (single data source). +// +// Responses: +// 200: okResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) DeleteDataSourceByUID(c *models.ReqContext) response.Response { uid := web.Params(c.Req)[":uid"] @@ -197,7 +267,19 @@ func (hs *HTTPServer) DeleteDataSourceByUID(c *models.ReqContext) response.Respo }) } -// DELETE /api/datasources/name/:name +// swagger:route DELETE /datasources/name/{name} datasources deleteDataSourceByName +// +// Delete an existing data source by name. +// +// If you are running Grafana Enterprise and have Fine-grained access control enabled +// you need to have a permission with action: `datasources:delete` and scopes: `datasources:*`, `datasources:name:*` and `datasources:name:test_datasource` (single data source). +// +// Responses: +// 200: deleteDataSourceByNameResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) DeleteDataSourceByName(c *models.ReqContext) response.Response { name := web.Params(c.Req)[":name"] @@ -242,7 +324,23 @@ func validateURL(cmdType string, url string) response.Response { return nil } -// POST /api/datasources/ +// swagger:route POST /datasources datasources addDataSource +// +// Create a data source. +// +// By defining `password` and `basicAuthPassword` under secureJsonData property +// Grafana encrypts them securely as an encrypted blob in the database. +// The response then lists the encrypted fields under secureJsonFields. +// +// If you are running Grafana Enterprise and have Fine-grained access control enabled +// you need to have a permission with action: `datasources:create` +// +// Responses: +// 200: createOrUpdateDatasourceResponse +// 401: unauthorisedError +// 403: forbiddenError +// 409: conflictError +// 500: internalServerError func (hs *HTTPServer) AddDataSource(c *models.ReqContext) response.Response { cmd := datasources.AddDataSourceCommand{} if err := web.Bind(c.Req, &cmd); err != nil { @@ -279,7 +377,27 @@ func (hs *HTTPServer) AddDataSource(c *models.ReqContext) response.Response { }) } -// PUT /api/datasources/:id +// swagger:route PUT /datasources/{id} datasources updateDataSourceByID +// +// Update an existing data source by its sequential ID. +// +// Similar to creating a data source, `password` and `basicAuthPassword` should be defined under +// secureJsonData in order to be stored securely as an encrypted blob in the database. Then, the +// encrypted fields are listed under secureJsonFields section in the response. +// +// If you are running Grafana Enterprise and have Fine-grained access control enabled +// you need to have a permission with action: `datasources:write` and scopes: `datasources:*`, `datasources:id:*` and `datasources:id:1` (single data source). +// +// Please refer to [updated API](#/datasources/updateDataSourceByUID) instead +// +// Deprecated: true +// +// Responses: +// 200: createOrUpdateDatasourceResponse +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError + func (hs *HTTPServer) UpdateDataSourceByID(c *models.ReqContext) response.Response { cmd := datasources.UpdateDataSourceCommand{} if err := web.Bind(c.Req, &cmd); err != nil { @@ -305,7 +423,22 @@ func (hs *HTTPServer) UpdateDataSourceByID(c *models.ReqContext) response.Respon return hs.updateDataSourceByID(c, ds, cmd) } -// PUT /api/datasources/:uid +// swagger:route PUT /datasources/uid/{uid} datasources updateDataSourceByUID +// +// Update an existing data source. +// +// Similar to creating a data source, `password` and `basicAuthPassword` should be defined under +// secureJsonData in order to be stored securely as an encrypted blob in the database. Then, the +// encrypted fields are listed under secureJsonFields section in the response. +// +// If you are running Grafana Enterprise and have Fine-grained access control enabled +// you need to have a permission with action: `datasources:write` and scopes: `datasources:*`, `datasources:uid:*` and `datasources:uid:1` (single data source). +// +// Responses: +// 200: createOrUpdateDatasourceResponse +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) UpdateDataSourceByUID(c *models.ReqContext) response.Response { cmd := datasources.UpdateDataSourceCommand{} if err := web.Bind(c.Req, &cmd); err != nil { @@ -395,7 +528,18 @@ func (hs *HTTPServer) getRawDataSourceByUID(ctx context.Context, uid string, org return query.Result, nil } -// Get /api/datasources/name/:name +// swagger:route GET /datasources/name/{name} datasources getDataSourceByName +// +// Get a single data source by Name. +// +// If you are running Grafana Enterprise and have Fine-grained access control enabled +// you need to have a permission with action: `datasources:read` and scopes: `datasources:*`, `datasources:name:*` and `datasources:name:test_datasource` (single data source). +// +// Responses: +// 200: getDataSourceResponse +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) GetDataSourceByName(c *models.ReqContext) response.Response { query := datasources.GetDataSourceQuery{Name: web.Params(c.Req)[":name"], OrgId: c.OrgId} @@ -410,7 +554,19 @@ func (hs *HTTPServer) GetDataSourceByName(c *models.ReqContext) response.Respons return response.JSON(http.StatusOK, &dto) } -// Get /api/datasources/id/:name +// swagger:route GET /datasources/id/{name} datasources getDataSourceIdByName +// +// Get data source Id by Name. +// +// If you are running Grafana Enterprise and have Fine-grained access control enabled +// you need to have a permission with action: `datasources:read` and scopes: `datasources:*`, `datasources:name:*` and `datasources:name:test_datasource` (single data source). +// +// Responses: +// 200: getDataSourceIDResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) GetDataSourceIdByName(c *models.ReqContext) response.Response { query := datasources.GetDataSourceQuery{Name: web.Params(c.Req)[":name"], OrgId: c.OrgId} @@ -429,7 +585,21 @@ func (hs *HTTPServer) GetDataSourceIdByName(c *models.ReqContext) response.Respo return response.JSON(http.StatusOK, &dtos) } -// /api/datasources/:id/resources/* +// swagger:route GET /datasources/{id}/resources/{datasource_proxy_route} datasources callDatasourceResourceByID +// +// Fetch data source resources by Id. +// +// Please refer to [updated API](#/datasources/callDatasourceResourceWithUID) instead +// +// Deprecated: true +// +// Responses: +// 200: okResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) CallDatasourceResource(c *models.ReqContext) { datasourceID, err := strconv.ParseInt(web.Params(c.Req)[":id"], 10, 64) if err != nil { @@ -455,7 +625,17 @@ func (hs *HTTPServer) CallDatasourceResource(c *models.ReqContext) { hs.callPluginResourceWithDataSource(c, plugin.ID, ds) } -// /api/datasources/uid/:uid/resources/* +// swagger:route GET /datasources/uid/{uid}/resources/{datasource_proxy_route} datasources callDatasourceResourceWithUID +// +// Fetch data source resources. +// +// Responses: +// 200: okResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) CallDatasourceResourceWithUID(c *models.ReqContext) { dsUID := web.Params(c.Req)[":uid"] if !util.IsValidShortUID(dsUID) { @@ -517,8 +697,16 @@ func (hs *HTTPServer) convertModelToDtos(ctx context.Context, ds *datasources.Da return dto } -// CheckDatasourceHealthWithUID sends a health check request to the plugin datasource -// /api/datasource/uid/:uid/health +// swagger:route GET /datasources/uid/{uid}/health datasources checkDatasourceHealthWithUID +// +// Sends a health check request to the plugin datasource identified by the UID. +// +// Responses: +// 200: okResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) CheckDatasourceHealthWithUID(c *models.ReqContext) response.Response { dsUID := web.Params(c.Req)[":uid"] if !util.IsValidShortUID(dsUID) { @@ -535,8 +723,20 @@ func (hs *HTTPServer) CheckDatasourceHealthWithUID(c *models.ReqContext) respons return hs.checkDatasourceHealth(c, ds) } -// CheckDatasourceHealth sends a health check request to the plugin datasource -// /api/datasource/:id/health +// swagger:route GET /datasources/{id}/health datasources checkDatasourceHealthByID +// +// Sends a health check request to the plugin datasource identified by the ID. +// +// Please refer to [updated API](#/datasources/checkDatasourceHealthWithUID) instead +// +// Deprecated: true +// +// Responses: +// 200: okResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) CheckDatasourceHealth(c *models.ReqContext) response.Response { datasourceID, err := strconv.ParseInt(web.Params(c.Req)[":id"], 10, 64) if err != nil { @@ -648,3 +848,176 @@ func (hs *HTTPServer) filterDatasourcesByQueryPermission(ctx context.Context, us return query.Result, nil } + +// swagger:parameters checkDatasourceHealthByID +type CheckDatasourceHealthByIDParams struct { + // in:path + // required:true + DatasourceID string `json:"id"` +} + +// swagger:parameters callDatasourceResourceByID +type CallDatasourceResourceByIDParams struct { + // in:path + // required:true + DatasourceID string `json:"id"` +} + +// swagger:parameters deleteDataSourceByID +type DeleteDataSourceByIDParams struct { + // in:path + // required:true + DatasourceID string `json:"id"` +} + +// swagger:parameters getDataSourceByID +type GetDataSourceByIDParams struct { + // in:path + // required:true + DatasourceID string `json:"id"` +} + +// swagger:parameters checkDatasourceHealthWithUID +type CheckDatasourceHealthWithUIDParams struct { + // in:path + // required:true + DatasourceUID string `json:"uid"` +} + +// swagger:parameters callDatasourceResourceWithUID +type CallDatasourceResourceWithUIDParams struct { + // in:path + // required:true + DatasourceUID string `json:"uid"` +} + +// swagger:parameters deleteDataSourceByUID +type DeleteDataSourceByUIDParams struct { + // in:path + // required:true + DatasourceUID string `json:"uid"` +} + +// swagger:parameters getDataSourceByUID +type GetDataSourceByUIDParams struct { + // in:path + // required:true + DatasourceUID string `json:"uid"` +} + +// swagger:parameters getDataSourceByName +type GetDataSourceByNameParams struct { + // in:path + // required:true + DatasourceName string `json:"name"` +} + +// swagger:parameters deleteDataSourceByName +type DeleteDataSourceByNameParams struct { + // in:path + // required:true + DatasourceName string `json:"name"` +} + +// swagger:parameters getDataSourceIdByName +type GetDataSourceIdByNameParams struct { + // in:path + // required:true + DatasourceName string `json:"name"` +} + +// swagger:parameters addDataSource +type AddDataSourceParams struct { + // in:body + // required:true + Body datasources.AddDataSourceCommand +} + +// swagger:parameters updateDataSourceByID +type UpdateDataSourceByIDParams struct { + // in:body + // required:true + Body datasources.UpdateDataSourceCommand + // in:path + // required:true + DatasourceID string `json:"id"` +} + +// swagger:parameters updateDataSourceByUID +type UpdateDataSourceByUIDParams struct { + // in:body + // required:true + Body datasources.UpdateDataSourceCommand + // in:path + // required:true + DatasourceUID string `json:"uid"` +} + +// swagger:response getDataSourcesResponse +type GetDataSourcesResponse struct { + // The response message + // in: body + Body dtos.DataSourceList `json:"body"` +} + +// swagger:response getDataSourceResponse +type GetDataSourceResponse struct { + // The response message + // in: body + Body dtos.DataSource `json:"body"` +} + +// swagger:response createOrUpdateDatasourceResponse +type CreateOrUpdateDatasourceResponse struct { + // The response message + // in: body + Body struct { + // ID Identifier of the new data source. + // required: true + // example: 65 + ID int64 `json:"id"` + + // Name of the new data source. + // required: true + // example: My Data source + Name string `json:"name"` + + // Message Message of the deleted dashboard. + // required: true + // example: Data source added + Message string `json:"message"` + + // Datasource properties + // required: true + Datasource dtos.DataSource `json:"datasource"` + } `json:"body"` +} + +// swagger:response getDataSourceIDResponse +type GetDataSourceIDresponse struct { + // The response message + // in: body + Body struct { + // ID Identifier of the data source. + // required: true + // example: 65 + ID int64 `json:"id"` + } `json:"body"` +} + +// swagger:response deleteDataSourceByNameResponse +type DeleteDataSourceByNameResponse struct { + // The response message + // in: body + Body struct { + // ID Identifier of the deleted data source. + // required: true + // example: 65 + ID int64 `json:"id"` + + // Message Message of the deleted dashboard. + // required: true + // example: Dashboard My Dashboard deleted + Message string `json:"message"` + } `json:"body"` +} diff --git a/pkg/api/docs/definitions/admin.go b/pkg/api/docs/definitions/admin.go deleted file mode 100644 index 999951af967..00000000000 --- a/pkg/api/docs/definitions/admin.go +++ /dev/null @@ -1,67 +0,0 @@ -package definitions - -import ( - "github.com/grafana/grafana/pkg/api/dtos" -) - -// swagger:route GET /admin/settings admin getSettings -// -// Fetch settings. -// -// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `settings:read` and scopes: `settings:*`, `settings:auth.saml:` and `settings:auth.saml:enabled` (property level). -// -// Security: -// - basic: -// -// Responses: -// 200: getSettingsResponse -// 401: unauthorisedError -// 403: forbiddenError - -// swagger:route GET /admin/stats admin getStats -// -// Fetch Grafana Stats. -// -// Only works with Basic Authentication (username and password). See introduction for an explanation. -// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `server:stats:read`. -// -// Responses: -// 200: getStatsResponse -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route POST /admin/pause-all-alerts admin pauseAllAlerts -// -// Pause/unpause all (legacy) alerts. -// -// Security: -// - basic: -// -// Responses: -// 200: pauseAlertsResponse -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:parameters pauseAllAlerts -type PauseAllAlertsParams struct { - // in:body - // required:true - Body dtos.PauseAllAlertsCommand `json:"body"` -} - -// swagger:response pauseAlertsResponse -type PauseAllAlertsResponse struct { - // in:body - Body struct { - // AlertsAffected is the number of the affected alerts. - // required: true - AlertsAffected int64 `json:"alertsAffected"` - // required: true - Message string `json:"message"` - // Alert result state - // required true - State string `json:"state"` - } `json:"body"` -} diff --git a/pkg/api/docs/definitions/admin_ldap.go b/pkg/api/docs/definitions/admin_ldap.go deleted file mode 100644 index 47492c595eb..00000000000 --- a/pkg/api/docs/definitions/admin_ldap.go +++ /dev/null @@ -1,75 +0,0 @@ -package definitions - -// swagger:route POST /admin/ldap/reload admin_ldap reloadLDAP -// -// Reloads the LDAP configuration. -// -// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `ldap.config:reload`. -// -// Security: -// - basic: -// -// Responses: -// 200: okResponse -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route POST /admin/ldap/sync/{user_id} admin_ldap syncLDAPUser -// -// Enables a single Grafana user to be synchronized against LDAP. -// -// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `ldap.user:sync`. -// -// Security: -// - basic: -// -// Responses: -// 200: okResponse -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route GET /admin/ldap/{user_name} admin_ldap getLDAPUser -// -// Finds an user based on a username in LDAP. This helps illustrate how would the particular user be mapped in Grafana when synced. -// -// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `ldap.user:read`. -// -// Security: -// - basic: -// -// Responses: -// 200: okResponse -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route GET /admin/ldap/status admin_ldap getLDAPStatus -// -// Attempts to connect to all the configured LDAP servers and returns information on whenever they're available or not. -// -// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `ldap.status:read`. -// -// Security: -// - basic: -// -// Responses: -// 200: okResponse -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:parameters getLDAPUser -type GetLDAPUserParams struct { - // in:path - // required:true - UserName string `json:"user_name"` -} - -// swagger:parameters syncLDAPUser -type SyncLDAPUserParams struct { - // in:path - // required:true - UserID int64 `json:"user_id"` -} diff --git a/pkg/api/docs/definitions/admin_provisioning.go b/pkg/api/docs/definitions/admin_provisioning.go deleted file mode 100644 index f2acfde3d7b..00000000000 --- a/pkg/api/docs/definitions/admin_provisioning.go +++ /dev/null @@ -1,81 +0,0 @@ -package definitions - -// swagger:route POST /admin/provisioning/dashboards/reload admin_provisioning reloadProvisionedDashboards -// -// Reload dashboard provisioning configurations. -// -// Reloads the provisioning config files for dashboards again. It won’t return until the new provisioned entities are already stored in the database. In case of dashboards, it will stop polling for changes in dashboard files and then restart it with new configurations after returning. -// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `provisioning:reload` and scope `provisioners:dashboards`. -// -// Security: -// - basic: -// -// Responses: -// 200: okResponse -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route POST /admin/provisioning/datasources/reload admin_provisioning reloadProvisionedDatasources -// -// Reload datasource provisioning configurations. -// -// Reloads the provisioning config files for datasources again. It won’t return until the new provisioned entities are already stored in the database. In case of dashboards, it will stop polling for changes in dashboard files and then restart it with new configurations after returning. -// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `provisioning:reload` and scope `provisioners:datasources`. -// -// Security: -// - basic: -// -// Responses: -// 200: okResponse -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route POST /admin/provisioning/plugins/reload admin_provisioning reloadProvisionedPlugins -// -// Reload plugin provisioning configurations. -// -// Reloads the provisioning config files for plugins again. It won’t return until the new provisioned entities are already stored in the database. In case of dashboards, it will stop polling for changes in dashboard files and then restart it with new configurations after returning. -// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `provisioning:reload` and scope `provisioners:plugin`. -// -// Security: -// - basic: -// -// Responses: -// 200: okResponse -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route POST /admin/provisioning/notifications/reload admin_provisioning reloadProvisionedAlertNotifiers -// -// Reload legacy alert notifier provisioning configurations. -// -// Reloads the provisioning config files for legacy alert notifiers again. It won’t return until the new provisioned entities are already stored in the database. In case of dashboards, it will stop polling for changes in dashboard files and then restart it with new configurations after returning. -// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `provisioning:reload` and scope `provisioners:notifications`. -// -// Security: -// - basic: -// -// Responses: -// 200: okResponse -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route POST /admin/provisioning/accesscontrol/reload admin_provisioning reloadProvisionedAccessControl -// -// Reload access control provisioning configurations. -// -// Reloads the provisioning config files for access control again. It won’t return until the new provisioned entities are already stored in the database. In case of dashboards, it will stop polling for changes in dashboard files and then restart it with new configurations after returning. -// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `provisioning:reload` and scope `provisioners:accesscontrol`. -// -// Security: -// - basic: -// -// Responses: -// 200: okResponse -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError diff --git a/pkg/api/docs/definitions/admin_users.go b/pkg/api/docs/definitions/admin_users.go deleted file mode 100644 index 899560fdbbd..00000000000 --- a/pkg/api/docs/definitions/admin_users.go +++ /dev/null @@ -1,309 +0,0 @@ -package definitions - -import ( - "github.com/grafana/grafana/pkg/api/dtos" - "github.com/grafana/grafana/pkg/models" - "github.com/grafana/grafana/pkg/setting" -) - -// swagger:route POST /admin/users admin_users createUser -// -// Create new user. -// -// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `users:create`. -// Note that OrgId is an optional parameter that can be used to assign a new user to a different organization when `auto_assign_org` is set to `true`. -// -// Security: -// - basic: -// -// Responses: -// 200: createUserResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 412: preconditionFailedError -// 500: internalServerError - -// swagger:route PUT /admin/users/{user_id}/password admin_users setPassword -// -// Set password for user. -// -// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `users.password:update` and scope `global.users:*`. -// -// Security: -// - basic: -// -// Responses: -// 200: okResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route PUT /admin/users/{user_id}/permissions admin_users setPermissions -// -// Set permissions for user. -// -// Only works with Basic Authentication (username and password). See introduction for an explanation. -// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `users.permissions:update` and scope `global.users:*`. -// -// Responses: -// 200: okResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route DELETE /admin/users/{user_id} admin_users deleteUser -// -// Delete global User. -// -// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `users:delete` and scope `global.users:*`. -// -// Security: -// - basic: -// -// Responses: -// 200: okResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route POST /admin/users/{user_id}/disable admin_users disableUser -// -// Disable user. -// -// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `users:disable` and scope `global.users:1` (userIDScope). -// -// Security: -// - basic: -// -// Responses: -// 200: okResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route POST /admin/users/{user_id}/enable admin_users enableUser -// -// Enable user. -// -// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `users:enable` and scope `global.users:1` (userIDScope). -// -// Security: -// - basic: -// -// Responses: -// 200: okResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route GET /admin/users/{user_id}/quotas admin_users getUserQuota -// -// Fetch user quota. -// -// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `users.quotas:list` and scope `global.users:1` (userIDScope). -// -// Security: -// - basic: -// -// Responses: -// 200: getQuotaResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route PUT /admin/users/{user_id}/quotas/{quota_target} admin_users updateUserQuota -// -// Update user quota. -// -// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `users.quotas:update` and scope `global.users:1` (userIDScope). -// -// Security: -// - basic: -// -// Responses: -// 200: okResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route GET /admin/users/{user_id}/auth-tokens admin_users getAuthTokens -// -// Return a list of all auth tokens (devices) that the user currently have logged in from. -// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `users.authtoken:list` and scope `global.users:*`. -// -// Security: -// - basic: -// -// Responses: -// 200: getAuthTokensResponse -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route POST /admin/users/{user_id}/revoke-auth-token admin_users revokeAuthToken -// -// Revoke auth token for user. -// -// Revokes the given auth token (device) for the user. User of issued auth token (device) will no longer be logged in and will be required to authenticate again upon next activity. -// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `users.authtoken:update` and scope `global.users:*`. -// -// Security: -// - basic: -// -// Responses: -// 200: okResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route POST /admin/users/{user_id}/logout admin_users logoutUser -// -// Logout user revokes all auth tokens (devices) for the user. User of issued auth tokens (devices) will no longer be logged in and will be required to authenticate again upon next activity. -// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `users.logout` and scope `global.users:*`. -// -// Security: -// - basic: -// -// Responses: -// 200: okResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:parameters setPassword -type SetPasswordParams struct { - // in:body - // required:true - Body dtos.AdminUpdateUserPasswordForm `json:"body"` - // in:path - // required:true - UserID int64 `json:"user_id"` -} - -// swagger:parameters deleteUser -type DeleteUserParams struct { - // in:path - // required:true - UserID int64 `json:"user_id"` -} - -// swagger:parameters enableUser -type EnableUserParams struct { - // in:path - // required:true - UserID int64 `json:"user_id"` -} - -// swagger:parameters disableUser -type DisableUserParams struct { - // in:path - // required:true - UserID int64 `json:"user_id"` -} - -// swagger:parameters getUserQuota -type GetUserQuotaParams struct { - // in:path - // required:true - UserID int64 `json:"user_id"` -} - -// swagger:parameters updateUserQuota -type UpdateUserQuotaParams struct { - // in:path - // required:true - QuotaTarget string `json:"quota_target"` - // in:path - // required:true - UserID int64 `json:"user_id"` -} - -// swagger:parameters getAuthTokens -type GetAuthTokensParams struct { - // in:path - // required:true - UserID int64 `json:"user_id"` -} - -// swagger:parameters logoutUser -type LogoutUserParams struct { - // in:path - // required:true - UserID int64 `json:"user_id"` -} - -// swagger:parameters revokeAuthToken -type RevokeAuthTokenParams struct { - // in:body - // required:true - Body models.RevokeAuthTokenCmd `json:"body"` - // in:path - // required:true - UserID int64 `json:"user_id"` -} - -// swagger:parameters createUser -type CreateUserParam struct { - // in:body - // required:true - Body dtos.AdminCreateUserForm `json:"body"` -} - -// swagger:parameters updateUserQuota -type UpdateUserQuotaParam struct { - // in:body - // required:true - Body models.UpdateUserQuotaCmd `json:"body"` -} - -// swagger:parameters setPermissions -type SetPermissionsParams struct { - // in:body - // required:true - Body dtos.AdminUpdateUserPermissionsForm `json:"body"` - // in:path - // required:true - UserID int64 `json:"user_id"` -} - -// swagger:response createUserResponse -type CreateUserResponse struct { - // in:body - Body models.UserIdDTO `json:"body"` -} - -// swagger:response getSettingsResponse -type GetSettingsResponse struct { - // in:body - Body setting.SettingsBag `json:"body"` -} - -// swagger:response getStatsResponse -type GetStatsResponse struct { - // in:body - Body models.AdminStats `json:"body"` -} - -// swagger:response getAuthTokensResponse -type GetAuthTokensResponse struct { - // in:body - Body []*models.UserToken `json:"body"` -} - -// swagger:response getQuotaResponse -type GetQuotaResponseResponse struct { - // in:body - Body []*models.UserQuotaDTO `json:"body"` -} diff --git a/pkg/api/docs/definitions/annotations.go b/pkg/api/docs/definitions/annotations.go deleted file mode 100644 index 4906a012381..00000000000 --- a/pkg/api/docs/definitions/annotations.go +++ /dev/null @@ -1,273 +0,0 @@ -package definitions - -import ( - "github.com/grafana/grafana/pkg/api/dtos" - "github.com/grafana/grafana/pkg/services/annotations" -) - -// swagger:route GET /annotations annotations getAnnotations -// -// Find Annotations. -// -// Starting in Grafana v6.4 regions annotations are now returned in one entity that now includes the timeEnd property. -// -// Responses: -// 200: getAnnotationsResponse -// 401: unauthorisedError -// 500: internalServerError - -// swagger:route GET /annotations/{annotation_id} annotations getAnnotation -// -// Get Annotation by Id. -// -// Responses: -// 200: getAnnotationResponse -// 401: unauthorisedError -// 500: internalServerError - -// swagger:route POST /annotations/mass-delete annotations massDeleteAnnotations -// -// Delete multiple annotations. -// -// Responses: -// 200: okResponse -// 401: unauthorisedError -// 500: internalServerError - -// swagger:route POST /annotations annotations createAnnotation -// -// Create Annotation. -// -// Creates an annotation in the Grafana database. The dashboardId and panelId fields are optional. If they are not specified then an organization annotation is created and can be queried in any dashboard that adds the Grafana annotations data source. When creating a region annotation include the timeEnd property. -// The format for `time` and `timeEnd` should be epoch numbers in millisecond resolution. -// The response for this HTTP request is slightly different in versions prior to v6.4. In prior versions you would also get an endId if you where creating a region. But in 6.4 regions are represented using a single event with time and timeEnd properties. -// -// Responses: -// 200: createAnnotationResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route POST /annotations/graphite annotations createGraphiteAnnotation -// -// Create Annotation in Graphite format. -// -// Creates an annotation by using Graphite-compatible event format. The `when` and `data` fields are optional. If `when` is not specified then the current time will be used as annotation’s timestamp. The `tags` field can also be in prior to Graphite `0.10.0` format (string with multiple tags being separated by a space). -// -// Responses: -// 200: createAnnotationResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route PUT /annotations/{annotation_id} annotations updateAnnotation -// -// Update Annotation. -// -// Updates all properties of an annotation that matches the specified id. To only update certain property, consider using the Patch Annotation operation. -// -// Responses: -// 200: okResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route PATCH /annotations/{annotation_id} annotations patchAnnotation -// -// Patch Annotation -// -// Updates one or more properties of an annotation that matches the specified ID. -// This operation currently supports updating of the `text`, `tags`, `time` and `timeEnd` properties. -// This is available in Grafana 6.0.0-beta2 and above. -// -// Responses: -// 200: okResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route DELETE /annotations/{annotation_id} annotations deleteAnnotation -// -// Delete Annotation By ID. -// -// Deletes the annotation that matches the specified ID. -// -// Responses: -// 200: okResponse -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route GET /annotations/tags annotations getAnnotationTags -// -// Find Annotations Tags. -// -// Find all the event tags created in the annotations. -// -// Responses: -// 200: getAnnotationTagsResponse -// 401: unauthorisedError -// 500: internalServerError - -// swagger:parameters getAnnotation -type GetAnnotationParams struct { - // in:path - // required:true - AnnotationID string `json:"annotation_id"` -} - -// swagger:parameters deleteAnnotation -type DeleteAnnotationParams struct { - // in:path - // required:true - AnnotationID string `json:"annotation_id"` -} - -// swagger:parameters getAnnotations -type GetAnnotationsParams struct { - // Find annotations created after specific epoch datetime in milliseconds. - // in:query - // required:false - From int64 `json:"from"` - // Find annotations created before specific epoch datetime in milliseconds. - // in:query - // required:false - To int64 `json:"to"` - // Limit response to annotations created by specific user. - // in:query - // required:false - UserID int64 `json:"userId"` - // Find annotations for a specified alert. - // in:query - // required:false - AlertID int64 `json:"alertId"` - // Find annotations that are scoped to a specific dashboard - // in:query - // required:false - DashboardID int64 `json:"dashboardId"` - // Find annotations that are scoped to a specific dashboard - // in:query - // required:false - DashboardUID string `json:"dashboardUID"` - // Find annotations that are scoped to a specific panel - // in:query - // required:false - PanelID int64 `json:"panelId"` - // Max limit for results returned. - // in:query - // required:false - Limit int64 `json:"limit"` - // Use this to filter organization annotations. Organization annotations are annotations from an annotation data source that are not connected specifically to a dashboard or panel. You can filter by multiple tags. - // in:query - // required:false - // type: array - // collectionFormat: multi - Tags []string `json:"tags"` - // Return alerts or user created annotations - // in:query - // required:false - // Description: - // * `alert` - // * `annotation` - // enum: alert,annotation - Type string `json:"type"` - // Match any or all tags - // in:query - // required:false - MatchAny bool `json:"matchAny"` -} - -// swagger:parameters getAnnotationTags -type GetAnnotationTagssParams struct { - // Tag is a string that you can use to filter tags. - // in:query - // required:false - Tag string `json:"tag"` - // Max limit for results returned. - // in:query - // required:false - // default: 100 - Limit string `json:"limit"` -} - -// swagger:parameters massDeleteAnnotations -type MassDeleteAnnotationsParams struct { - // in:body - // required:true - Body dtos.MassDeleteAnnotationsCmd `json:"body"` -} - -// swagger:parameters createAnnotation -type CreateAnnotationParams struct { - // in:body - // required:true - Body dtos.PostAnnotationsCmd `json:"body"` -} - -// swagger:parameters createGraphiteAnnotation -type CreateGraphiteAnnotationParams struct { - // in:body - // required:true - Body dtos.PostGraphiteAnnotationsCmd `json:"body"` -} - -// swagger:parameters updateAnnotation -type UpdateAnnotationParams struct { - // in:path - // required:true - AnnotationID string `json:"annotation_id"` - // in:body - // required:true - Body dtos.UpdateAnnotationsCmd `json:"body"` -} - -// swagger:parameters patchAnnotation -type PatchAnnotationParams struct { - // in:path - // required:true - AnnotationID string `json:"annotation_id"` - // in:body - // required:true - Body dtos.PatchAnnotationsCmd `json:"body"` -} - -// swagger:response getAnnotationsResponse -type GetAnnotationsResponse struct { - // The response message - // in: body - Body []*annotations.ItemDTO `json:"body"` -} - -// swagger:response getAnnotationResponse -type GetAnnotationResponse struct { - // The response message - // in: body - Body *annotations.ItemDTO `json:"body"` -} - -// swagger:response createAnnotationResponse -type CreateAnnotationResponse struct { - // The response message - // in: body - Body struct { - // ID Identifier of the created annotation. - // required: true - // example: 65 - ID int64 `json:"id"` - - // Message Message of the created annotation. - // required: true - Message string `json:"message"` - } `json:"body"` -} - -// swagger:response getAnnotationTagsResponse -type GetAnnotationTagsResponse struct { - // The response message - // in: body - Body annotations.GetAnnotationTagsResponse `json:"body"` -} diff --git a/pkg/api/docs/definitions/apikey.go b/pkg/api/docs/definitions/apikey.go deleted file mode 100644 index 3121a616680..00000000000 --- a/pkg/api/docs/definitions/apikey.go +++ /dev/null @@ -1,81 +0,0 @@ -package definitions - -import ( - "github.com/grafana/grafana/pkg/api/dtos" - "github.com/grafana/grafana/pkg/models" -) - -// swagger:route GET /auth/keys api_keys getAPIkeys -// -// Get auth keys. -// -// Will return auth keys. -// -// Responses: -// 200: getAPIkeyResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route POST /auth/keys api_keys addAPIkey -// -// Creates an API key. -// -// Will return details of the created API key -// -// Responses: -// 200: postAPIkeyResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 409: conflictError -// 500: internalServerError - -// swagger:route DELETE /auth/keys/{id} api_keys deleteAPIkey -// -// Delete API key. -// -// Responses: -// 200: okResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:parameters getAPIkeys -type GetAPIkeysParams struct { - // Show expired keys - // in:query - // required:false - // default:false - IncludeExpired bool `json:"includeExpired"` -} - -// swagger:parameters addAPIkey -type AddAPIkeyParams struct { - // in:body - // required:true - Body models.AddApiKeyCommand -} - -// swagger:parameters deleteAPIkey -type DeleteAPIkeyParams struct { - // in:path - // required:true - ID int64 `json:"id"` -} - -// swagger:response getAPIkeyResponse -type GetAPIkeyResponse struct { - // The response message - // in: body - Body []*dtos.ApiKeyDTO `json:"body"` -} - -// swagger:response postAPIkeyResponse -type PostAPIkeyResponse struct { - // The response message - // in: body - Body dtos.NewApiKeyResult `json:"body"` -} diff --git a/pkg/api/docs/definitions/correlations.go b/pkg/api/docs/definitions/correlations.go deleted file mode 100644 index c9367dfa7bb..00000000000 --- a/pkg/api/docs/definitions/correlations.go +++ /dev/null @@ -1,60 +0,0 @@ -package definitions - -import ( - "github.com/grafana/grafana/pkg/services/correlations" -) - -// swagger:route POST /datasources/uid/{sourceUID}/correlations correlations createCorrelation -// -// Add correlation. -// -// Responses: -// 200: createCorrelationResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:parameters createCorrelation -type CreateCorrelationParams struct { - // in:body - // required:true - Body correlations.CreateCorrelationCommand `json:"body"` - // in:path - // required:true - SourceUID string `json:"sourceUID"` -} - -//swagger:response createCorrelationResponse -type CreateCorrelationResponse struct { - // in: body - Body correlations.CreateCorrelationResponse `json:"body"` -} - -// swagger:route DELETE /datasources/uid/{uid}/correlations/{correlationUID} correlations deleteCorrelation -// -// Delete a correlation. -// -// Responses: -// 200: deleteCorrelationResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:parameters deleteCorrelation -type DeleteCorrelationParams struct { - // in:path - // required:true - DatasourceUID string `json:"uid"` - // in:path - // required:true - CorrelationUID string `json:"correlationUID"` -} - -//swagger:response deleteCorrelationResponse -type DeleteCorrelationResponse struct { - // in: body - Body correlations.DeleteCorrelationResponse `json:"body"` -} diff --git a/pkg/api/docs/definitions/dashboard.go b/pkg/api/docs/definitions/dashboard.go deleted file mode 100644 index ddb9423ef38..00000000000 --- a/pkg/api/docs/definitions/dashboard.go +++ /dev/null @@ -1,272 +0,0 @@ -package definitions - -import ( - "github.com/grafana/grafana/pkg/api/dtos" - "github.com/grafana/grafana/pkg/models" - "github.com/grafana/grafana/pkg/services/dashboardimport" -) - -// swagger:route GET /dashboards/uid/{uid} dashboards getDashboardByUID -// -// Get dashboard by uid. -// -// Will return the dashboard given the dashboard unique identifier (uid). -// -// Responses: -// 200: dashboardResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// DeleteDashboardByUID swagger:route DELETE /dashboards/uid/{uid} dashboards deleteDashboardByUID -// -// Delete dashboard by uid. -// -// Will delete the dashboard given the specified unique identifier (uid). -// -// Responses: -// 200: deleteDashboardResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route POST /dashboards/calculate-diff dashboards calcDashboardDiff -// -// Perform diff on two dashboards. -// -// Produces: -// - application/json -// - text/html -// -// Responses: -// 200: dashboardDiffResponse -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route POST /dashboards/trim dashboards trimDashboard -// -// Trim defaults from dashboard. -// -// Responses: -// 200: trimDashboardResponse -// 401: unauthorisedError -// 500: internalServerError - -// swagger:route POST /dashboards/db dashboards postDashboard -// -// Create / Update dashboard -// -// Creates a new dashboard or updates an existing dashboard. -// -// Responses: -// 200: postDashboardResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 412: preconditionFailedError -// 422: unprocessableEntityError -// 500: internalServerError - -// swagger:route GET /dashboards/home dashboards getHomeDashboard -// -// Get home dashboard. -// -// Responses: -// 200: getHomeDashboardResponse -// 401: unauthorisedError -// 500: internalServerError - -// swagger:route GET /dashboards/tags dashboards getDashboardTags -// -// Get all dashboards tags of an organisation. -// -// Responses: -// 200: dashboardsTagsResponse -// 401: unauthorisedError -// 500: internalServerError - -// swagger:route POST /dashboards/import dashboards importDashboard -// -// Import dashboard. -// -// Responses: -// 200: importDashboardResponse -// 400: badRequestError -// 401: unauthorisedError -// 412: preconditionFailedError -// 422: unprocessableEntityError -// 500: internalServerError - -// swagger:parameters getDashboardByUID -type GetDashboardByUIDParams struct { - // in:path - // required:true - UID string `json:"uid"` -} - -// swagger:parameters deleteDashboardByUID -type DeleteDashboardByUIDParams struct { - // in:path - // required:true - UID string `json:"uid"` -} - -// swagger:parameters getDashboardPermissionsWithUid postDashboardPermissionsWithUid getDashboardVersionByUID -// swagger:parameters getDashboardVersionsByUID restoreDashboardVersionByUID -type UID struct { - // in:path - // required:true - UID string `json:"uid"` -} - -// swagger:parameters postDashboard -type PostDashboardParam struct { - // in:body - // required:true - Body models.SaveDashboardCommand -} - -// swagger:parameters calcDashboardDiff -type CalcDashboardDiffOptions struct { - // in:body - // required:true - Body struct { - Base dtos.CalculateDiffTarget `json:"base" binding:"Required"` - New dtos.CalculateDiffTarget `json:"new" binding:"Required"` - // The type of diff to return - // Description: - // * `basic` - // * `json` - // Enum: basic,json - DiffType string `json:"diffType" binding:"Required"` - } -} - -// swagger:parameters trimDashboard -type TrimDashboardParam struct { - // in:body - // required:true - Body models.TrimDashboardCommand -} - -// swagger:parameters importDashboard -type ImportDashboardParam struct { - // in:body - // required:true - Body dashboardimport.ImportDashboardRequest -} - -// swagger:response dashboardResponse -type DashboardResponse struct { - // The response message - // in: body - Body dtos.DashboardFullWithMeta `json:"body"` -} - -// swagger:response deleteDashboardResponse -type DeleteDashboardResponse struct { - // The response message - // in: body - Body struct { - // ID Identifier of the deleted dashboard. - // required: true - // example: 65 - ID int64 `json:"id"` - - // Title Title of the deleted dashboard. - // required: true - // example: My Dashboard - Title string `json:"title"` - - // Message Message of the deleted dashboard. - // required: true - // example: Dashboard My Dashboard deleted - Message string `json:"message"` - } `json:"body"` -} - -// Create/update dashboard response. -// swagger:response postDashboardResponse -type PostDashboardResponse struct { - // in: body - Body struct { - // Status status of the response. - // required: true - // example: success - Status string `json:"status"` - - // Slug The slug of the dashboard. - // required: true - // example: my-dashboard - Slug string `json:"title"` - - // Version The version of the dashboard. - // required: true - // example: 2 - Verion int64 `json:"version"` - - // ID The unique identifier (id) of the created/updated dashboard. - // required: true - // example: 1 - ID string `json:"id"` - - // UID The unique identifier (uid) of the created/updated dashboard. - // required: true - // example: nHz3SXiiz - UID string `json:"uid"` - - // URL The relative URL for accessing the created/updated dashboard. - // required: true - // example: /d/nHz3SXiiz/my-dashboard - URL string `json:"url"` - } `json:"body"` -} - -// Calculate dashboard diff response. -// swagger:response dashboardDiffResponse -type DashboardDiffResponse struct { - // in: body - Body []byte `json:"body"` -} - -// Trimmed dashboard response. -// swagger:response trimDashboardResponse -type TrimDashboardResponse struct { - // in: body - Body dtos.TrimDashboardFullWithMeta `json:"body"` -} - -// Home dashboard response. -// swagger:response getHomeDashboardResponse -type GetHomeDashboardResponse struct { - // in: body - Body GetHomeDashboardResponseBody `json:"body"` -} - -// swagger:response dashboardsTagsResponse -type DashboardsTagsResponse struct { - // in: body - Body []*models.DashboardTagCloudItem `json:"body"` -} - -// swagger:response importDashboardResponse -type ImportDashboardResponse struct { - // in: body - Body dashboardimport.ImportDashboardResponse `json:"body"` -} - -// Get home dashboard response. -// swagger:model GetHomeDashboardResponse -type GetHomeDashboardResponseBody struct { - // swagger:allOf - // required: false - dtos.DashboardFullWithMeta - - // swagger:allOf - // required: false - dtos.DashboardRedirect -} diff --git a/pkg/api/docs/definitions/dashboard_permissions.go b/pkg/api/docs/definitions/dashboard_permissions.go deleted file mode 100644 index d1411b0fb38..00000000000 --- a/pkg/api/docs/definitions/dashboard_permissions.go +++ /dev/null @@ -1,96 +0,0 @@ -package definitions - -import ( - "github.com/grafana/grafana/pkg/api/dtos" - "github.com/grafana/grafana/pkg/models" -) - -// swagger:route GET /dashboards/id/{DashboardID}/permissions dashboard_permissions getDashboardPermissions -// -// Gets all existing permissions for the given dashboard. -// -// Please refer to [updated API](#/dashboard_permissions/getDashboardPermissionsWithUid) instead -// -// Deprecated: true -// -// Responses: -// 200: getDashboardPermissionsResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route POST /dashboards/id/{DashboardID}/permissions dashboard_permissions postDashboardPermissions -// -// Updates permissions for a dashboard. -// -// Please refer to [updated API](#/dashboard_permissions/postDashboardPermissionsWithUid) instead -// -// This operation will remove existing permissions if they’re not included in the request. -// -// Deprecated: true -// -// Responses: -// 200: okResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route GET /dashboards/uid/{uid}/permissions dashboard_permissions getDashboardPermissionsWithUid -// -// Gets all existing permissions for the given dashboard. -// -// Responses: -// 200: getDashboardPermissionsResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route POST /dashboards/uid/{uid}/permissions dashboard_permissions postDashboardPermissionsWithUid -// -// Updates permissions for a dashboard. -// -// This operation will remove existing permissions if they’re not included in the request. -// -// Responses: -// 200: okResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:parameters getDashboardPermissions -type GetDashboardPermissionsParams struct { - // in:path - DashboardID int64 -} - -// swagger:parameters postDashboardPermissions -type PostDashboardPermissionsParams struct { - // in:body - // required:true - Body dtos.UpdateDashboardACLCommand - // in:path - DashboardID int64 -} - -// swagger:parameters postDashboardPermissionsWithUid -type PostDashboardPermissionsWithUIDParams struct { - // in:body - // required:true - Body dtos.UpdateDashboardACLCommand - // in:path - // required:true - // description: The dashboard UID - UID string `json:"uid"` -} - -// swagger:response getDashboardPermissionsResponse -type GetDashboardPermissionsResponse struct { - // in: body - Body []*models.DashboardACLInfoDTO `json:"body"` -} diff --git a/pkg/api/docs/definitions/dashboard_versions.go b/pkg/api/docs/definitions/dashboard_versions.go deleted file mode 100644 index cc927c0b28f..00000000000 --- a/pkg/api/docs/definitions/dashboard_versions.go +++ /dev/null @@ -1,132 +0,0 @@ -package definitions - -import ( - "github.com/grafana/grafana/pkg/api/dtos" - dashver "github.com/grafana/grafana/pkg/services/dashboardversion" -) - -// swagger:route GET /dashboards/id/{DashboardID}/versions dashboard_versions getDashboardVersions -// -// Gets all existing versions for the dashboard. -// -// Please refer to [updated API](#/dashboard_versions/getDashboardVersionsByUID) instead -// -// Deprecated: true -// -// Responses: -// 200: dashboardVersionsResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route GET /dashboards/uid/{uid}/versions dashboard_versions getDashboardVersionsByUID -// -// Gets all existing versions for the dashboard using UID. -// -// Responses: -// 200: dashboardVersionsResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route GET /dashboards/id/{DashboardID}/versions/{DashboardVersionID} dashboard_versions getDashboardVersion -// -// Get a specific dashboard version. -// -// Please refer to [updated API](#/dashboard_versions/getDashboardVersionByUID) instead -// -// Deprecated: true -// -// Responses: -// 200: dashboardVersionResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route GET /dashboards/uid/{uid}/versions/{DashboardVersionID} dashboard_versions getDashboardVersionByUID -// -// Get a specific dashboard version using UID. -// -// Responses: -// 200: dashboardVersionResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route POST /dashboards/id/{DashboardID}/restore dashboard_versions restoreDashboardVersion -// -// Restore a dashboard to a given dashboard version. -// -// Please refer to [updated API](#/dashboard_versions/restoreDashboardVersionByUID) instead -// -// Deprecated: true -// -// Responses: -// 200: postDashboardResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route POST /dashboards/uid/{uid}/restore dashboard_versions restoreDashboardVersionByUID -// -// Restore a dashboard to a given dashboard version using UID. -// -// Responses: -// 200: postDashboardResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:parameters getDashboardVersions getDashboardVersion restoreDashboardVersion -// swagger:parameters getDashboardPermissions -// swagger:parameters renderReportPDF -type DashboardIdParam struct { - // in:path - DashboardID int64 -} - -// swagger:parameters getDashboardVersion getDashboardVersionByUID -type DashboardVersionIdParam struct { - // in:path - DashboardVersionID int64 -} - -// swagger:parameters restoreDashboardVersion restoreDashboardVersionByUID -type RestoreVersionBodyParam struct { - // in:body - // required:true - Body dtos.RestoreDashboardVersionCommand -} - -// swagger:parameters getDashboardVersions getDashboardVersionsByUID -type GetDashboardVersionsParams struct { - // Maximum number of results to return - // in:query - // required:false - // default:0 - Limit int `json:"limit"` - - // Version to start from when returning queries - // in:query - // required:false - // default:0 - Start int `json:"start"` -} - -// swagger:response dashboardVersionsResponse -type DashboardVersionsResponse struct { - // in: body - Body []*dashver.DashboardVersionDTO `json:"body"` -} - -// swagger:response dashboardVersionResponse -type DashboardVersionResponse struct { - // in: body - Body *dashver.DashboardVersionMeta `json:"body"` -} diff --git a/pkg/api/docs/definitions/datasources.go b/pkg/api/docs/definitions/datasources.go deleted file mode 100644 index 1d6750c45de..00000000000 --- a/pkg/api/docs/definitions/datasources.go +++ /dev/null @@ -1,550 +0,0 @@ -package definitions - -import ( - "github.com/grafana/grafana/pkg/api/dtos" - "github.com/grafana/grafana/pkg/services/datasources" -) - -// swagger:route GET /datasources datasources getDatasources -// -// Get all data sources. -// -// If you are running Grafana Enterprise and have Fine-grained access control enabled -// you need to have a permission with action: `datasources:read` and scope: `datasources:*`. -// -// Responses: -// 200: getDatasourcesResponse -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route POST /datasources datasources addDatasource -// -// Create a data source. -// -// By defining `password` and `basicAuthPassword` under secureJsonData property -// Grafana encrypts them securely as an encrypted blob in the database. -// The response then lists the encrypted fields under secureJsonFields. -// -// If you are running Grafana Enterprise and have Fine-grained access control enabled -// you need to have a permission with action: `datasources:create` -// -// Responses: -// 200: createOrUpdateDatasourceResponse -// 401: unauthorisedError -// 403: forbiddenError -// 409: conflictError -// 500: internalServerError - -// swagger:route PUT /datasources/{id} datasources updateDatasourceByID -// -// Update an existing data source by its sequential ID. -// -// Similar to creating a data source, `password` and `basicAuthPassword` should be defined under -// secureJsonData in order to be stored securely as an encrypted blob in the database. Then, the -// encrypted fields are listed under secureJsonFields section in the response. -// -// If you are running Grafana Enterprise and have Fine-grained access control enabled -// you need to have a permission with action: `datasources:write` and scopes: `datasources:*`, `datasources:id:*` and `datasources:id:1` (single data source). -// -// Please refer to [updated API](#/datasources/updateDatasourceByUID) instead -// -// Deprecated: true -// -// Responses: -// 200: createOrUpdateDatasourceResponse -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route PUT /datasources/uid/{uid} datasources updateDatasourceByUID -// -// Update an existing data source. -// -// Similar to creating a data source, `password` and `basicAuthPassword` should be defined under -// secureJsonData in order to be stored securely as an encrypted blob in the database. Then, the -// encrypted fields are listed under secureJsonFields section in the response. -// -// If you are running Grafana Enterprise and have Fine-grained access control enabled -// you need to have a permission with action: `datasources:write` and scopes: `datasources:*`, `datasources:uid:*` and `datasources:uid:1` (single data source). -// -// Responses: -// 200: createOrUpdateDatasourceResponse -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route DELETE /datasources/{id} datasources deleteDatasourceByID -// -// Delete an existing data source by id. -// -// If you are running Grafana Enterprise and have Fine-grained access control enabled -// you need to have a permission with action: `datasources:delete` and scopes: `datasources:*`, `datasources:id:*` and `datasources:id:1` (single data source). -// -// Please refer to [updated API](#/datasources/deleteDatasourceByUID) instead -// -// Deprecated: true -// -// Responses: -// 200: okResponse -// 401: unauthorisedError -// 404: notFoundError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route DELETE /datasources/uid/{uid} datasources deleteDatasourceByUID -// -// Delete an existing data source by UID. -// -// If you are running Grafana Enterprise and have Fine-grained access control enabled -// you need to have a permission with action: `datasources:delete` and scopes: `datasources:*`, `datasources:uid:*` and `datasources:uid:kLtEtcRGk` (single data source). -// -// Responses: -// 200: okResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route DELETE /datasources/name/{name} datasources deleteDatasourceByName -// -// Delete an existing data source by name. -// -// If you are running Grafana Enterprise and have Fine-grained access control enabled -// you need to have a permission with action: `datasources:delete` and scopes: `datasources:*`, `datasources:name:*` and `datasources:name:test_datasource` (single data source). -// -// Responses: -// 200: deleteDatasourceByNameResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route GET /datasources/{id} datasources getDatasourceByID -// -// Get a single data source by Id. -// -// If you are running Grafana Enterprise and have Fine-grained access control enabled -// you need to have a permission with action: `datasources:read` and scopes: `datasources:*`, `datasources:id:*` and `datasources:id:1` (single data source). -// -// Please refer to [updated API](#/datasources/getDatasourceByUID) instead -// -// Deprecated: true -// -// Responses: -// 200: getDatasourceResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route GET /datasources/uid/{uid} datasources getDatasourceByUID -// -// Get a single data source by UID. -// -// If you are running Grafana Enterprise and have Fine-grained access control enabled -// you need to have a permission with action: `datasources:read` and scopes: `datasources:*`, `datasources:uid:*` and `datasources:uid:kLtEtcRGk` (single data source). -// -// Responses: -// 200: getDatasourceResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route GET /datasources/{id}/health datasources checkDatasourceHealthByID -// -// Check data source health by Id. -// -// Please refer to [updated API](#/datasources/checkDatasourceHealth) instead -// -// Deprecated: true -// -// Responses: -// 200: okResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route GET /datasources/uid/{uid}/health datasources checkDatasourceHealth -// -// Check data source health by Id. -// -// Responses: -// 200: okResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route GET /datasources/{id}/resources/{datasource_proxy_route} datasources fetchDatasourceResourcesByID -// -// Fetch data source resources by Id. -// -// Please refer to [updated API](#/datasources/fetchDatasourceResources) instead -// -// Deprecated: true -// -// Responses: -// 200: okResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route GET /datasources/uid/{uid}/resources/{datasource_proxy_route} datasources fetchDatasourceResources -// -// Fetch data source resources. -// -// Responses: -// 200: okResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route GET /datasources/name/{name} datasources getDatasourceByName -// -// Get a single data source by Name. -// -// If you are running Grafana Enterprise and have Fine-grained access control enabled -// you need to have a permission with action: `datasources:read` and scopes: `datasources:*`, `datasources:name:*` and `datasources:name:test_datasource` (single data source). -// -// Responses: -// 200: getDatasourceResponse -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route GET /datasources/id/{name} datasources getDatasourceIdByName -// -// Get data source Id by Name. -// -// If you are running Grafana Enterprise and have Fine-grained access control enabled -// you need to have a permission with action: `datasources:read` and scopes: `datasources:*`, `datasources:name:*` and `datasources:name:test_datasource` (single data source). -// -// Responses: -// 200: getDatasourceIDresponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route GET /datasources/proxy/{id}/{datasource_proxy_route} datasources datasourceProxyGETcalls -// -// Data source proxy GET calls. -// -// Proxies all calls to the actual data source. -// -// Please refer to [updated API](#/datasources/datasourceProxyGETByUIDcalls) instead -// -// Deprecated: true -// -// Responses: -// 200: -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route GET /datasources/proxy/uid/{uid}/{datasource_proxy_route} datasources datasourceProxyGETByUIDcalls -// -// Data source proxy GET calls. -// -// Proxies all calls to the actual data source. -// -// Responses: -// 200: -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route POST /datasources/proxy/{id}/{datasource_proxy_route} datasources datasourceProxyPOSTcalls -// -// Data source proxy POST calls. -// -// Proxies all calls to the actual data source. The data source should support POST methods for the specific path and role as defined -// -// Please refer to [updated API](#/datasources/datasourceProxyPOSTByUIDcalls) instead -// -// Deprecated: true -// -// Responses: -// 201: -// 202: -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route POST /datasources/proxy/uid/{uid}/{datasource_proxy_route} datasources datasourceProxyPOSTByUIDcalls -// -// Data source proxy POST calls. -// -// Proxies all calls to the actual data source. The data source should support POST methods for the specific path and role as defined -// -// Responses: -// 201: -// 202: -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route DELETE /datasources/proxy/{id}/{datasource_proxy_route} datasources datasourceProxyDELETEcalls -// -// Data source proxy DELETE calls. -// -// Proxies all calls to the actual data source. -// -// Please refer to [updated API](#/datasources/datasourceProxyDELETEByUIDcalls) instead -// -// Deprecated: true -// -// Responses: -// 202: -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route DELETE /datasources/proxy/uid/{uid}/{datasource_proxy_route} datasources datasourceProxyDELETEByUIDcalls -// -// Data source proxy DELETE calls. -// -// Proxies all calls to the actual data source. -// -// Responses: -// 202: -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:parameters updateDatasourceByID datasourceProxyDELETEcalls -// swagger:parameters checkDatasourceHealthByID fetchDatasourceResourcesByID -type DatasourceID struct { - // in:path - // required:true - DatasourceID string `json:"id"` -} - -// swagger:parameters deleteDatasourceByID -type DeleteDatasourceByIDParams struct { - // in:path - // required:true - DatasourceID string `json:"id"` -} - -// swagger:parameters getDatasourceByID -type GetDatasourceByIDParams struct { - // in:path - // required:true - DatasourceID string `json:"id"` -} - -// swagger:parameters datasourceProxyGETcalls -type DatasourceProxyGETcallsParams struct { - // in:path - // required:true - DatasourceProxyRoute string `json:"datasource_proxy_route"` - // in:path - // required:true - DatasourceID string `json:"id"` -} - -// swagger:parameters datasourceProxyDELETEByUIDcalls -// swagger:parameters checkDatasourceHealth fetchDatasourceResources -type DatasourceUID struct { - // in:path - // required:true - DatasourceUID string `json:"uid"` -} - -// swagger:parameters deleteDatasourceByUID -type DeleteDatasourceByUIDParams struct { - // in:path - // required:true - DatasourceUID string `json:"uid"` -} - -// swagger:parameters getDatasourceByUID -type GetDatasourceByUIDParams struct { - // in:path - // required:true - DatasourceUID string `json:"uid"` -} - -// swagger:parameters datasourceProxyGETByUIDcalls -type DatasourceProxyGETByUIDcallsParams struct { - // in:path - // required:true - DatasourceProxyRoute string `json:"datasource_proxy_route"` - // in:path - // required:true - DatasourceUID string `json:"uid"` -} - -// swagger:parameters getDatasourceByName -type GetDatasourceByNameParams struct { - // in:path - // required:true - DatasourceName string `json:"name"` -} - -// swagger:parameters deleteDatasourceByName -type DeleteDatasourceByNameParams struct { - // in:path - // required:true - DatasourceName string `json:"name"` -} - -// swagger:parameters getDatasourceIdByName -type GetDatasourceIdByNameParams struct { - // in:path - // required:true - DatasourceName string `json:"name"` -} - -// swagger:parameters datasourceProxyDELETEcalls -// swagger:parameters datasourceProxyDELETEByUIDcalls -// swagger:parameters fetchDatasourceResources fetchDatasourceResourcesByID -type DatasourceProxyRouteParam struct { - // in:path - // required:true - DatasourceProxyRoute string `json:"datasource_proxy_route"` -} - -// swagger:parameters datasourceProxyPOSTcalls -type DatasourceProxyPOSTcallsParams struct { - // in:body - // required:true - DatasourceProxyParam interface{} - // in:path - // required:true - DatasourceProxyRoute string `json:"datasource_proxy_route"` - // in:path - // required:true - DatasourceID string `json:"id"` -} - -// swagger:parameters datasourceProxyPOSTByUIDcalls -type DatasourceProxyPOSTByUIDcallsParams struct { - // in:body - // required:true - DatasourceProxyParam interface{} - // in:path - // required:true - DatasourceProxyRoute string `json:"datasource_proxy_route"` - // in:path - // required:true - DatasourceUID string `json:"uid"` -} - -// swagger:parameters addDatasource -type AddDatasourceParams struct { - // in:body - // required:true - Body datasources.AddDataSourceCommand -} - -// swagger:parameters updateDatasourceByID -type UpdateDatasourceParams struct { - // in:body - // required:true - Body datasources.UpdateDataSourceCommand - // in:path - // required:true - DatasourceID string `json:"id"` -} - -// swagger:parameters updateDatasourceByUID -type UpdateDatasourceByUIDParams struct { - // in:body - // required:true - Body datasources.UpdateDataSourceCommand - // in:path - // required:true - DatasourceUID string `json:"uid"` -} - -// swagger:response getDatasourcesResponse -type GetDatasourcesResponse struct { - // The response message - // in: body - Body dtos.DataSourceList `json:"body"` -} - -// swagger:response getDatasourceResponse -type GetDatasourceResponse struct { - // The response message - // in: body - Body dtos.DataSource `json:"body"` -} - -// swagger:response createOrUpdateDatasourceResponse -type CreateOrUpdateDatasourceResponse struct { - // The response message - // in: body - Body struct { - // ID Identifier of the new data source. - // required: true - // example: 65 - ID int64 `json:"id"` - - // Name of the new data source. - // required: true - // example: My Data source - Name string `json:"name"` - - // Message Message of the deleted dashboard. - // required: true - // example: Data source added - Message string `json:"message"` - - // Datasource properties - // required: true - Datasource dtos.DataSource `json:"datasource"` - } `json:"body"` -} - -// swagger:response getDatasourceIDresponse -type GetDatasourceIDresponse struct { - // The response message - // in: body - Body struct { - // ID Identifier of the data source. - // required: true - // example: 65 - ID int64 `json:"id"` - } `json:"body"` -} - -// swagger:response deleteDatasourceByNameResponse -type DeleteDatasourceByNameResponse struct { - // The response message - // in: body - Body struct { - // ID Identifier of the deleted data source. - // required: true - // example: 65 - ID int64 `json:"id"` - - // Message Message of the deleted dashboard. - // required: true - // example: Dashboard My Dashboard deleted - Message string `json:"message"` - } `json:"body"` -} diff --git a/pkg/api/docs/definitions/ds.go b/pkg/api/docs/definitions/ds.go deleted file mode 100644 index e37d465e453..00000000000 --- a/pkg/api/docs/definitions/ds.go +++ /dev/null @@ -1,35 +0,0 @@ -package definitions - -import ( - "github.com/grafana/grafana-plugin-sdk-go/backend" - "github.com/grafana/grafana/pkg/api/dtos" -) - -// swagger:route POST /ds/query ds queryMetricsWithExpressions -// -// Query metrics with expressions -// -// If you are running Grafana Enterprise and have Fine-grained access control enabled -// you need to have a permission with action: `datasources:query`. -// -// Responses: -// 200: queryDataResponse -// 207: queryDataResponse -// 401: unauthorisedError -// 400: badRequestError -// 403: forbiddenError -// 500: internalServerError - -// swagger:parameters queryMetricsWithExpressions -type QueryMetricsWithExpressionsBodyParam struct { - // in:body - // required:true - Body dtos.MetricRequest `json:"body"` -} - -// swagger:response queryDataResponse -type QueryDataResponseResponse struct { - // The response message - // in: body - Body *backend.QueryDataResponse `json:"body"` -} diff --git a/pkg/api/docs/definitions/folder.go b/pkg/api/docs/definitions/folder.go deleted file mode 100644 index 3ffbde3474f..00000000000 --- a/pkg/api/docs/definitions/folder.go +++ /dev/null @@ -1,184 +0,0 @@ -package definitions - -import ( - "github.com/grafana/grafana/pkg/api/dtos" - "github.com/grafana/grafana/pkg/models" -) - -// swagger:route GET /folders folders getFolders -// -// Get all folders. -// -// Returns all folders that the authenticated user has permission to view. -// -// Responses: -// 200: getFoldersResponse -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route GET /folders/{folder_uid} folders getFolderByUID -// -// Get folder by uid. -// -// Responses: -// 200: folderResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route POST /folders folders createFolder -// -// Create folder. -// -// Responses: -// 200: folderResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 409: conflictError -// 500: internalServerError - -// swagger:route PUT /folders/{folder_uid} folders updateFolder -// -// Update folder. -// -// Responses: -// 200: folderResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 409: conflictError -// 500: internalServerError - -// swagger:route DELETE /folders/{folder_uid} folders deleteFolder -// -// Delete folder. -// -// Deletes an existing folder identified by UID along with all dashboards (and their alerts) stored in the folder. This operation cannot be reverted. -// -// Responses: -// 200: deleteFolderResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route GET /folders/id/{folder_id} folders getFolderByID -// -// Get folder by id. -// -// Returns the folder identified by id. -// -// Responses: -// 200: folderResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:parameters getFolders -type GetFoldersParams struct { - // Limit the maximum number of folders to return - // in:query - // required:false - // default:1000 - Limit int64 `json:"limit"` - // Page index for starting fetching folders - // in:query - // required:false - // default:1 - Page int64 `json:"page"` -} - -// swagger:parameters getFolderByUID updateFolder deleteFolder -// swagger:parameters getFolderPermissions -type FolderUIDParam struct { - // in:path - // required:true - FolderUID string `json:"folder_uid"` -} - -// swagger:parameters updateFolderPermissions -type PostDashboardPermissionsParam struct { - // in:path - // required:true - FolderUID string `json:"folder_uid"` - // in:body - // required:true - Body dtos.UpdateDashboardACLCommand -} - -// swagger:parameters getFolderByID -type FolderIDParam struct { - // in:path - // required:true - FolderID int64 `json:"folder_id"` -} - -// swagger:parameters createFolder -type CreateFolderParam struct { - // in:body - // required:true - Body models.CreateFolderCommand `json:"body"` -} - -// swagger:parameters updateFolder -type UpdateFolderParam struct { - // To change the unique identifier (uid), provide another one. - // To overwrite an existing folder with newer version, set `overwrite` to `true`. - // Provide the current version to safelly update the folder: if the provided version differs from the stored one the request will fail, unless `overwrite` is `true`. - // - // in:body - // required:true - Body models.UpdateFolderCommand `json:"body"` -} - -// swagger:parameters deleteFolder -type DeleteFolderParam struct { - // If `true` any Grafana 8 Alerts under this folder will be deleted. - // Set to `false` so that the request will fail if the folder contains any Grafana 8 Alerts. - // in:query - // required:false - // default:false - ForceDeleteRules bool `json:"forceDeleteRules"` -} - -// swagger:response getFoldersResponse -type GetFoldersResponse struct { - // The response message - // in: body - Body []dtos.FolderSearchHit `json:"body"` -} - -// swagger:response folderResponse -type FolderResponse struct { - // The response message - // in: body - Body dtos.Folder `json:"body"` -} - -// swagger:response deleteFolderResponse -type DeleteFolderResponse struct { - // The response message - // in: body - Body struct { - // ID Identifier of the deleted folder. - // required: true - // example: 65 - ID int64 `json:"id"` - - // Title of the deleted folder. - // required: true - // example: My Folder - Title string `json:"title"` - - // Message Message of the deleted folder. - // required: true - // example: Folder My Folder deleted - Message string `json:"message"` - } `json:"body"` -} diff --git a/pkg/api/docs/definitions/folder_permissions.go b/pkg/api/docs/definitions/folder_permissions.go deleted file mode 100644 index 77054f14a0c..00000000000 --- a/pkg/api/docs/definitions/folder_permissions.go +++ /dev/null @@ -1,23 +0,0 @@ -package definitions - -// swagger:route GET /folders/{folder_uid}/permissions folder_permissions getFolderPermissions -// -// Gets all existing permissions for the folder with the given `uid`. -// -// Responses: -// 200: getDashboardPermissionsResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route POST /folders/{folder_uid}/permissions folder_permissions updateFolderPermissions -// -// Updates permissions for a folder. This operation will remove existing permissions if they’re not included in the request. -// -// Responses: -// 200: okResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError diff --git a/pkg/api/docs/definitions/legacy_alert_notifications.go b/pkg/api/docs/definitions/legacy_alert_notifications.go deleted file mode 100644 index 751b7356f11..00000000000 --- a/pkg/api/docs/definitions/legacy_alert_notifications.go +++ /dev/null @@ -1,237 +0,0 @@ -package definitions - -import ( - "github.com/grafana/grafana/pkg/api/dtos" - "github.com/grafana/grafana/pkg/models" -) - -// swagger:route GET /alert-notifications legacy_alerts_notification_channels getAlertNotificationChannels -// -// Get all notification channels. -// -// Returns all notification channels that the authenticated user has permission to view. -// -// Responses: -// 200: getAlertNotificationChannelsResponse -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route GET /alert-notifications/lookup legacy_alerts_notification_channels lookupAlertNotificationChannels -// -// Get all notification channels (lookup) -// -// Returns all notification channels, but with less detailed information. Accessible by any authenticated user and is mainly used by providing alert notification channels in Grafana UI when configuring alert rule. -// -// Responses: -// 200: lookupAlertNotificationChannelsResponse -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route POST /alert-notifications/test legacy_alerts_notification_channels notificationChannelTest -// -// Test notification channel. -// -// Sends a test notification to the channel. -// -// Responses: -// 200: okResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 412: SMTPNotEnabledError -// 500: internalServerError - -// swagger:route POST /alert-notifications legacy_alerts_notification_channels createAlertNotificationChannel -// -// Create notification channel. -// -// You can find the full list of [supported notifiers](https://grafana.com/docs/grafana/latest/alerting/old-alerting/notifications/#list-of-supported-notifiers) on the alert notifiers page. -// -// Responses: -// 200: getAlertNotificationChannelResponse -// 401: unauthorisedError -// 403: forbiddenError -// 409: conflictError -// 500: internalServerError - -// swagger:route PUT /alert-notifications/{notification_channel_id} legacy_alerts_notification_channels updateAlertNotificationChannel -// -// Update notification channel by ID. -// -// Updates an existing notification channel identified by ID. -// -// Responses: -// 200: getAlertNotificationChannelResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route GET /alert-notifications/{notification_channel_id} legacy_alerts_notification_channels getAlertNotificationChannelByID -// -// Get notification channel by ID. -// -// Returns the notification channel given the notification channel ID. -// -// Responses: -// 200: getAlertNotificationChannelResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route DELETE /alert-notifications/{notification_channel_id} legacy_alerts_notification_channels deleteAlertNotificationChannel -// -// Delete alert notification by ID. -// -// Deletes an existing notification channel identified by ID. -// -// Responses: -// 200: okResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route GET /alert-notifications/uid/{notification_channel_uid} legacy_alerts_notification_channels getAlertNotificationChannelByUID -// -// Get notification channel by UID -// -// Returns the notification channel given the notification channel UID. -// -// Responses: -// 200: getAlertNotificationChannelResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route PUT /alert-notifications/uid/{notification_channel_uid} legacy_alerts_notification_channels updateAlertNotificationChannelByUID -// -// Update notification channel by UID. -// -// Updates an existing notification channel identified by uid. -// -// Responses: -// 200: getAlertNotificationChannelResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route DELETE /alert-notifications/uid/{notification_channel_uid} legacy_alerts_notification_channels deleteAlertNotificationChannelByUID -// -// Delete alert notification by UID. -// -// Deletes an existing notification channel identified by UID. -// -// Responses: -// 200: deleteAlertNotificationChannelResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:parameters deleteAlertNotificationChannel -type DeleteAlertNotificationChannelParams struct { - // in:path - // required:true - NotificationID int64 `json:"notification_channel_id"` -} - -// swagger:parameters getAlertNotificationChannelByID -type GetAlertNotificationChannelByIDParams struct { - // in:path - // required:true - NotificationID int64 `json:"notification_channel_id"` -} - -// swagger:parameters deleteAlertNotificationChannelByUID -type DeleteAlertNotificationChannelByUIDParams struct { - // in:path - // required:true - NotificationUID string `json:"notification_channel_uid"` -} - -// swagger:parameters getAlertNotificationChannelByUID -type GetAlertNotificationChannelByUIDParams struct { - // in:path - // required:true - NotificationUID string `json:"notification_channel_uid"` -} - -// swagger:parameters notificationChannelTest -type NotificationChannelTestParams struct { - // in:body - // required:true - Body dtos.NotificationTestCommand `json:"body"` -} - -// swagger:parameters createAlertNotificationChannel -type CreateAlertNotificationChannelParams struct { - // in:body - // required:true - Body models.CreateAlertNotificationCommand `json:"body"` -} - -// swagger:parameters updateAlertNotificationChannel -type UpdateAlertNotificationChannelParams struct { - // in:body - // required:true - Body models.UpdateAlertNotificationCommand `json:"body"` - // in:path - // required:true - NotificationID int64 `json:"notification_channel_id"` -} - -// swagger:parameters updateAlertNotificationChannelByUID -type UpdateAlertNotificationChannelBYUIDParams struct { - // in:body - // required:true - Body models.UpdateAlertNotificationWithUidCommand `json:"body"` - // in:path - // required:true - NotificationUID string `json:"notification_channel_uid"` -} - -// swagger:response getAlertNotificationChannelsResponse -type GetAlertNotificationChannelsResponse struct { - // The response message - // in: body - Body []*dtos.AlertNotification `json:"body"` -} - -// swagger:response lookupAlertNotificationChannelsResponse -type LookupAlertNotificationChannelsResponse struct { - // The response message - // in: body - Body []*dtos.AlertNotificationLookup `json:"body"` -} - -// swagger:response getAlertNotificationChannelResponse -type GetAlertNotificationChannelResponse struct { - // The response message - // in: body - Body *dtos.AlertNotification `json:"body"` -} - -// swagger:response deleteAlertNotificationChannelResponse -type DeleteAlertNotificationChannelResponse struct { - // The response message - // in: body - Body struct { - // ID Identifier of the deleted notification channel. - // required: true - // example: 65 - ID int64 `json:"id"` - - // Message Message of the deleted notificatiton channel. - // required: true - Message string `json:"message"` - } `json:"body"` -} - -// swagger:response SMTPNotEnabledError -type SMTPNotEnabledError PreconditionFailedError diff --git a/pkg/api/docs/definitions/legacy_alerting.go b/pkg/api/docs/definitions/legacy_alerting.go deleted file mode 100644 index 06a8bd2d5b1..00000000000 --- a/pkg/api/docs/definitions/legacy_alerting.go +++ /dev/null @@ -1,180 +0,0 @@ -package definitions - -import ( - "github.com/grafana/grafana/pkg/api/dtos" - "github.com/grafana/grafana/pkg/models" -) - -// swagger:route GET /alerts legacy_alerts getAlerts -// -// Get legacy alerts. -// -// Responses: -// 200: getAlertsResponse -// 401: unauthorisedError -// 500: internalServerError - -// swagger:route GET /alerts/{alert_id} legacy_alerts getAlertByID -// -// Get alert by ID. -// -// “evalMatches” data in the response is cached in the db when and only when the state of the alert changes (e.g. transitioning from “ok” to “alerting” state). -// If data from one server triggers the alert first and, before that server is seen leaving alerting state, a second server also enters a state that would trigger the alert, the second server will not be visible in “evalMatches” data. -// -// Responses: -// 200: getAlertResponse -// 401: unauthorisedError -// 500: internalServerError - -// swagger:route POST /alerts/{alert_id}/pause legacy_alerts pauseAlert -// -// Pause/unpause alert by id. -// -// Responses: -// 200: pauseAlertResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route POST /alerts/test legacy_alerts testAlert -// -// Test alert. -// -// Responses: -// 200: testAlertResponse -// 400: badRequestError -// 422: unprocessableEntityError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route GET /alerts/states-for-dashboard legacy_alerts getDashboardStates -// -// Get alert states for a dashboard. -// -// Responses: -// Responses: -// 200: getDashboardStatesResponse -// 400: badRequestError -// 500: internalServerError - -// swagger:parameters getAlertByID -type GetAlertByIDParams struct { - // in:path - // required:true - AlertID string `json:"alert_id"` -} - -// swagger:parameters pauseAlert -type PauseAlertParams struct { - // in:path - // required:true - AlertID string `json:"alert_id"` - // in:body - // required:true - Body dtos.PauseAlertCommand `json:"body"` -} - -// swagger:parameters getAlerts -type GetAlertsParams struct { - // Limit response to alerts in specified dashboard(s). You can specify multiple dashboards. - // in:query - // required:false - DashboardID []string `json:"dashboardId"` - // Limit response to alert for a specified panel on a dashboard. - // in:query - // required:false - PanelID int64 `json:"panelId"` - // Limit response to alerts having a name like this value. - // in:query - // required: false - Query string `json:"query"` - // Return alerts with one or more of the following alert states - // in:query - // required:false - // Description: - // * `all` - // * `no_data` - // * `paused` - // * `alerting` - // * `ok` - // * `pending` - // * `unknown` - // enum: all,no_data,paused,alerting,ok,pending,unknown - State string `json:"state"` - // Limit response to X number of alerts. - // in:query - // required:false - Limit int64 `json:"limit"` - // Limit response to alerts of dashboards in specified folder(s). You can specify multiple folders - // in:query - // required:false - // type array - // collectionFormat: multi - FolderID []string `json:"folderId"` - // Limit response to alerts having a dashboard name like this value./ Limit response to alerts having a dashboard name like this value. - // in:query - // required:false - DashboardQuery string `json:"dashboardQuery"` - // Limit response to alerts of dashboards with specified tags. To do an “AND” filtering with multiple tags, specify the tags parameter multiple times - // in:query - // required:false - // type: array - // collectionFormat: multi - DashboardTag []string `json:"dashboardTag"` -} - -// swagger:parameters testAlert -type TestAlertParams struct { - // in:body - Body dtos.AlertTestCommand `json:"body"` -} - -// swagger:parameters getDashboardStates -type GetDashboardStatesParams struct { - // in:query - // required: true - DashboardID int64 `json:"dashboardId"` -} - -// swagger:response getAlertsResponse -type GetAlertsResponse struct { - // The response message - // in: body - Body []*models.AlertListItemDTO `json:"body"` -} - -// swagger:response getAlertResponse -type GetAlertResponse struct { - // The response message - // in: body - Body *models.Alert `json:"body"` -} - -// swagger:response pauseAlertResponse -type PauseAlertResponse struct { - // in:body - Body struct { - // required: true - AlertID int64 `json:"alertId"` - // required: true - Message string `json:"message"` - // Alert result state - // required true - State string `json:"state"` - } `json:"body"` -} - -// swagger:response testAlertResponse -type TestAlertResponse struct { - // The response message - // in: body - Body *dtos.AlertTestResult `json:"body"` -} - -// swagger:response getDashboardStatesResponse -type GetDashboardStatesResponse struct { - // The response message - // in: body - Body []*models.AlertStateInfoDTO `json:"body"` -} diff --git a/pkg/api/docs/definitions/library_elements.go b/pkg/api/docs/definitions/library_elements.go deleted file mode 100644 index a350ff3fe36..00000000000 --- a/pkg/api/docs/definitions/library_elements.go +++ /dev/null @@ -1,214 +0,0 @@ -package definitions - -import ( - "github.com/grafana/grafana/pkg/services/libraryelements" -) - -// swagger:route GET /library-elements library_elements getLibraryElements -// -// Get all library elements. -// -// Returns a list of all library elements the authenticated user has permission to view. -// Use the `perPage` query parameter to control the maximum number of library elements returned; the default limit is `100`. -// You can also use the `page` query parameter to fetch library elements from any page other than the first one. -// -// Responses: -// 200: getLibraryElementsResponse -// 401: unauthorisedError -// 500: internalServerError - -// swagger:route GET /library-elements/{library_element_uid} library_elements getLibraryElementByUID -// -// Get library element by UID. -// -// Returns a library element with the given UID. -// -// Responses: -// 200: getLibraryElementResponse -// 401: unauthorisedError -// 404: notFoundError -// 500: internalServerError - -// swagger:route GET /library-elements/name/{library_element_name} library_elements getLibraryElementByName -// -// Get library element by name. -// -// Returns a library element with the given name. -// -// Responses: -// 200: getLibraryElementResponse -// 401: unauthorisedError -// 404: notFoundError -// 500: internalServerError - -// swagger:route GET /library-elements/{library_element_uid}/connections/ library_elements getLibraryElementConnections -// -// Get library element connections. -// -// Returns a list of connections for a library element based on the UID specified. -// -// Responses: -// 200: getLibraryElementConnectionsResponse -// 401: unauthorisedError -// 404: notFoundError -// 500: internalServerError - -// swagger:route POST /library-elements library_elements createLibraryElement -// -// Create library element. -// -// Creates a new library element. -// -// Responses: -// 200: getLibraryElementResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route PATCH /library-elements/{library_element_uid} library_elements updateLibraryElement -// -// Update library element. -// -// Updates an existing library element identified by uid. -// -// Responses: -// 200: getLibraryElementResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 412: preconditionFailedError -// 500: internalServerError - -// swagger:route DELETE /library-elements/{library_element_uid} library_elements deleteLibraryElementByUID -// -// Delete library element. -// -// Deletes an existing library element as specified by the UID. This operation cannot be reverted. -// You cannot delete a library element that is connected. This operation cannot be reverted. -// -// Responses: -// 200: okResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:parameters getLibraryElementByUID getLibraryElementConnections -type LibraryElementByUID struct { - // in:path - // required:true - UID string `json:"library_element_uid"` -} - -// swagger:parameters getLibraryElementByUID -type GetLibraryElementByUIDParams struct { - // in:path - // required:true - UID string `json:"library_element_uid"` -} - -// swagger:parameters GetLibraryElementConnectionsParams -type GetLibraryElementConnectionsParams struct { - // in:path - // required:true - UID string `json:"library_element_uid"` -} - -// swagger:parameters deleteLibraryElementByUID -type DeleteLibraryElementByUIDParams struct { - // in:path - // required:true - UID string `json:"library_element_uid"` -} - -// swagger:parameters getLibraryElementByName -type LibraryElementByNameParams struct { - // in:path - // required:true - Name string `json:"library_element_name"` -} - -// swagger:parameters getLibraryElements -type GetLibraryElementsParams struct { - // Part of the name or description searched for. - // in:query - // required:false - SearchString string `json:"searchString"` - // Kind of element to search for. - // in:query - // required:false - // Description: - // * 1 - library panels - // * 2 - library variables - // enum: 1,2 - Kind int `json:"kind"` - // Sort order of elements. - // in:query - // required:false - // Description: - // * alpha-asc: ascending - // * alpha-desc: descending - // Enum: alpha-asc,alpha-desc - SortDirection string `json:"sortDirection"` - // A comma separated list of types to filter the elements by - // in:query - // required:false - TypeFilter string `json:"typeFilter"` - // Element UID to exclude from search results. - // in:query - // required:false - ExcludeUID string `json:"excludeUid"` - // A comma separated list of folder ID(s) to filter the elements by. - // in:query - // required:false - FolderFilter string `json:"folderFilter"` - // The number of results per page. - // in:query - // required:false - // default: 100 - PerPage int `json:"perPage"` - // The page for a set of records, given that only perPage records are returned at a time. Numbering starts at 1. - // in:query - // required:false - // default: 1 - Page int `json:"page"` -} - -// swagger:parameters createLibraryElement -type CreateLibraryElementParams struct { - // in:body - // required:true - Body libraryelements.CreateLibraryElementCommand `json:"body"` -} - -// swagger:parameters updateLibraryElement -type UpdateLibraryElementParam struct { - // in:body - // required:true - Body libraryelements.PatchLibraryElementCommand `json:"body"` - // in:path - // required:true - UID string `json:"library_element_uid"` -} - -// swagger:response getLibraryElementsResponse -type GetLibraryElementsResponse struct { - // in: body - Body libraryelements.LibraryElementSearchResponse `json:"body"` -} - -// swagger:response getLibraryElementResponse -type GetLibraryElementResponse struct { - // in: body - Body libraryelements.LibraryElementResponse `json:"body"` -} - -// swagger:response getLibraryElementConnectionsResponse -type GetLibraryElementConnectionsResponse struct { - // in: body - Body libraryelements.LibraryElementConnectionsResponse `json:"body"` -} diff --git a/pkg/api/docs/definitions/meta.go b/pkg/api/docs/definitions/meta.go deleted file mode 100644 index 560196f4291..00000000000 --- a/pkg/api/docs/definitions/meta.go +++ /dev/null @@ -1,31 +0,0 @@ -// Package api Grafana HTTP API. -// -// The Grafana backend exposes an HTTP API, the same API is used by the frontend to do -// everything from saving dashboards, creating users and updating data sources. -// -// Schemes: http, https -// BasePath: /api -// Version: 0.0.1 -// License: GNU Affero General Public License v3.0 https://www.gnu.org/licenses/agpl-3.0.en.html -// Contact: Grafana Labs https://grafana.com -// -// Consumes: -// - application/json -// -// Produces: -// - application/json -// -// Security: -// - basic: -// - api_key: -// -// SecurityDefinitions: -// basic: -// type: basic -// api_key: -// type: apiKey -// name: Authorization -// in: header -// -// swagger:meta -package definitions diff --git a/pkg/api/docs/definitions/org.go b/pkg/api/docs/definitions/org.go deleted file mode 100644 index e4bf75ba95c..00000000000 --- a/pkg/api/docs/definitions/org.go +++ /dev/null @@ -1,195 +0,0 @@ -package definitions - -import ( - "github.com/grafana/grafana/pkg/api/dtos" - "github.com/grafana/grafana/pkg/models" -) - -// swagger:route GET /org current_org_details getOrg -// -// Get current Organization -// -// Responses: -// 200: getOrgResponse -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route GET /org/users current_org_details getOrgUsers -// -// Get all users within the current organization. -// -// Returns all org users within the current organization. Accessible to users with org admin role. -// If you are running Grafana Enterprise and have Fine-grained access control enabled -// you need to have a permission with action: `org.users:read` with scope `users:*`. -// -// Responses: -// 200: getOrgUsersResponse -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route GET /org/users/lookup current_org_details lookupOrgUsers -// -// Get all users within the current organization (lookup) -// -// Returns all org users within the current organization, but with less detailed information. -// Accessible to users with org admin role, admin in any folder or admin of any team. -// Mainly used by Grafana UI for providing list of users when adding team members and when editing folder/dashboard permissions. -// -// Responses: -// 200: lookupOrgUsersResponse -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route PATCH /org/users/{user_id} current_org_details updateOrgUser -// -// Updates the given user -// -// If you are running Grafana Enterprise and have Fine-grained access control enabled -// you need to have a permission with action: `org.users.role:update` with scope `users:*`. -// -// Responses: -// 200: okResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route DELETE /org/users/{user_id} current_org_details deleteOrgUser -// -// Delete user in current organization -// -// If you are running Grafana Enterprise and have Fine-grained access control enabled -// you need to have a permission with action: `org.users:remove` with scope `users:*`. -// -// Responses: -// 200: okResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route PUT /org current_org_details updateOrg -// -// Update current Organization. -// -// Responses: -// 200: okResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route PUT /org/address current_org_details updateOrgAddress -// -// Update current Organization's address. -// -// Responses: -// 200: okResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route POST /org/users current_org_details addOrgUser -// -// Add a new user to the current organization -// -// Adds a global user to the current organization. -// -// If you are running Grafana Enterprise and have Fine-grained access control enabled -// you need to have a permission with action: `org.users:add` with scope `users:*`. -// -// Responses: -// 200: okResponse -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:parameters updateOrgAddress -type UpdateOrgAddressParams struct { - // in:body - // required:true - Body dtos.UpdateOrgAddressForm `json:"body"` -} - -// swagger:parameters updateOrgUser -type UpdateOrgUserParams struct { - // in:body - // required:true - Body models.UpdateOrgUserCommand `json:"body"` - // in:path - // required:true - UserID int64 `json:"user_id"` -} - -// swagger:parameters deleteOrgUser -type DeleteOrgUserParams struct { - // in:path - // required:true - UserID int64 `json:"user_id"` -} - -// swagger:parameters updateOrg -type UpdateOrgParams struct { - // in:body - // required:true - Body dtos.UpdateOrgForm `json:"body"` -} - -// swagger:parameters addOrgUser -type AddOrgUserParams struct { - // in:body - // required:true - Body models.AddOrgUserCommand `json:"body"` -} - -// swagger:parameters lookupOrgUsers -type LookupOrgUsersParams struct { - // in:query - // required:false - Query string `json:"query"` - // in:query - // required:false - Limit int `json:"limit"` -} - -// swagger:response getOrgResponse -type GetOrgResponse struct { - // The response message - // in: body - Body models.OrgDetailsDTO `json:"body"` -} - -// swagger:response getOrgUsersResponse -type GetOrgUsersResponse struct { - // The response message - // in: body - Body []*models.OrgUserDTO `json:"body"` -} - -// swagger:response lookupOrgUsersResponse -type LookupOrgUsersResponse struct { - // The response message - // in: body - Body []*dtos.UserLookupDTO `json:"body"` -} - -// swagger:response addOrgUser -type AddOrgUser struct { - // The response message - // in: body - Body struct { - // ID Identifier of the added user. - // required: true - // example: 65 - UsedID int64 `json:"id"` - - // Message Message of the added user. - // required: true - // example: Data source added - Message string `json:"message"` - } `json:"body"` -} diff --git a/pkg/api/docs/definitions/org_invites.go b/pkg/api/docs/definitions/org_invites.go deleted file mode 100644 index 12d972820e0..00000000000 --- a/pkg/api/docs/definitions/org_invites.go +++ /dev/null @@ -1,60 +0,0 @@ -package definitions - -import ( - "github.com/grafana/grafana/pkg/api/dtos" - "github.com/grafana/grafana/pkg/models" -) - -// swagger:route GET /org/invites org_invites getInvites -// -// Get pending invites. -// -// Responses: -// 200: getInvitesResponse -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route POST /org/invites org_invites addInvite -// -// Add invite. -// -// Responses: -// 200: addOrgUser -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 412: SMTPNotEnabledError -// 500: internalServerError - -// swagger:route DELETE /org/{invitation_code}/invites org_invites revokeInvite -// -// Revoke invite. -// -// Responses: -// 200: okResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:parameters addInvite -type AddInviteParams struct { - // in:body - // required:true - Body dtos.AddInviteForm `json:"body"` -} - -// swagger:parameters revokeInvite -type RevokeInviteParams struct { - // in:path - // required:true - Code string `json:"invitation_code"` -} - -// swagger:response getInvitesResponse -type GetInvitesResponse struct { - // The response message - // in: body - Body []*models.TempUserDTO `json:"body"` -} diff --git a/pkg/api/docs/definitions/org_preferences.go b/pkg/api/docs/definitions/org_preferences.go deleted file mode 100644 index fe304b49e65..00000000000 --- a/pkg/api/docs/definitions/org_preferences.go +++ /dev/null @@ -1,42 +0,0 @@ -package definitions - -import "github.com/grafana/grafana/pkg/api/dtos" - -// swagger:route GET /org/preferences org_preferences getOrgPreferences -// -// Get Current Org Prefs. -// -// Responses: -// 200: getPreferencesResponse -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route PUT /org/preferences org_preferences updateOrgPreferences -// -// Update Current Org Prefs. -// -// Responses: -// 200: addOrgUser -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route PATCH /org/preferences org_preferences patchOrgPreferences -// -// Patch Current Org Prefs. -// -// Responses: -// 200: addOrgUser -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:parameters updateOrgPreferences -type UpdateOrgPreferencesParams struct { - // in:body - // required:true - Body dtos.UpdatePrefsCmd `json:"body"` -} diff --git a/pkg/api/docs/definitions/orgs.go b/pkg/api/docs/definitions/orgs.go deleted file mode 100644 index 849a21ce675..00000000000 --- a/pkg/api/docs/definitions/orgs.go +++ /dev/null @@ -1,337 +0,0 @@ -package definitions - -import ( - "github.com/grafana/grafana/pkg/api/dtos" - "github.com/grafana/grafana/pkg/models" -) - -// swagger:route GET /orgs/{org_id} orgs getOrgByID -// -// Get Organization by ID. -// -// Security: -// - basic: -// -// Responses: -// 200: getOrgResponse -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route GET /orgs/name/{org_name} orgs getOrgByName -// -// Get Organization by ID. -// -// Security: -// - basic: -// -// Responses: -// 200: getOrgResponse -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route POST /orgs orgs createOrg -// -// Create Organization. -// -// Only works if [users.allow_org_create](https://grafana.com/docs/grafana/latest/administration/configuration/#allow_org_create) is set. -// -// Responses: -// 200: createOrgResponse -// 401: unauthorisedError -// 403: forbiddenError -// 409: conflictError -// 500: internalServerError - -// swagger:route GET /orgs orgs searchOrg -// -// Search all Organizations -// -// Security: -// - basic: -// -// Responses: -// 200: searchOrgResponse -// 401: unauthorisedError -// 403: forbiddenError -// 409: conflictError -// 500: internalServerError - -// swagger:route PUT /orgs/{org_id} orgs adminUpdateOrg -// -// Update Organization. -// -// Security: -// - basic: -// -// Responses: -// 200: okResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route PUT /orgs/{org_id}/address orgs adminUpdateOrgAddress -// -// Update Organization's address. -// -// Responses: -// 200: okResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route DELETE /orgs/{org_id} orgs adminDeleteOrg -// -// Delete Organization. -// -// Security: -// - basic: -// -// Responses: -// 200: okResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route GET /orgs/{org_id}/users orgs adminGetOrgUsers -// -// Get Users in Organization. -// -// If you are running Grafana Enterprise and have Fine-grained access control enabled -// you need to have a permission with action: `org.users:read` with scope `users:*`. -// -// Security: -// - basic: -// -// Responses: -// 200: getOrgUsersResponse -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route POST /orgs/{org_id}/users orgs adminAddOrgUser -// -// Add a new user to the current organization -// -// Adds a global user to the current organization. -// -// If you are running Grafana Enterprise and have Fine-grained access control enabled -// you need to have a permission with action: `org.users:add` with scope `users:*`. -// -// Responses: -// 200: okResponse -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route PATCH /orgs/{org_id}/users/{user_id} orgs adminUpdateOrgUser -// -// Update Users in Organization. -// -// If you are running Grafana Enterprise and have Fine-grained access control enabled -// you need to have a permission with action: `org.users.role:update` with scope `users:*`. -// -// Responses: -// 200: okResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route DELETE /orgs/{org_id}/users/{user_id} orgs adminDeleteOrgUser -// -// Delete user in current organization -// -// If you are running Grafana Enterprise and have Fine-grained access control enabled -// you need to have a permission with action: `org.users:remove` with scope `users:*`. -// -// Responses: -// 200: okResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route GET /orgs/{org_id}/quotas orgs getOrgQuota -// -// Fetch Organization quota. -// -// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `orgs.quotas:read` and scope `org:id:1` (orgIDScope). -//list -// Responses: -// 200: getQuotaResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route PUT /orgs/{org_id}/quotas/{quota_target} orgs updateOrgQuota -// -// Update user quota. -// -// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `orgs.quotas:write` and scope `org:id:1` (orgIDScope). -// -// Security: -// - basic: -// -// Responses: -// 200: okResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:parameters getOrgQuota -type GetOrgQuotaParams struct { - // in:path - // required:true - OrgID int64 `json:"org_id"` -} - -// swagger:parameters adminUpdateOrgAddress -type AdminUpdateOrgAddressParams struct { - // in:body - // required:true - Body dtos.UpdateOrgAddressForm `json:"body"` - // in:path - // required:true - OrgID int64 `json:"org_id"` -} - -// swagger:parameters adminUpdateOrgUser -type AdminUpdateOrgUserParams struct { - // in:body - // required:true - Body models.UpdateOrgUserCommand `json:"body"` - // in:path - // required:true - OrgID int64 `json:"org_id"` - // in:path - // required:true - UserID int64 `json:"user_id"` -} - -// swagger:parameters getOrgByID -type GetOrgByIDParams struct { - // in:path - // required:true - OrgID int64 `json:"org_id"` -} - -// swagger:parameters adminDeleteOrgUser -type AdminDeleteOrgUserParams struct { - // in:path - // required:true - OrgID int64 `json:"org_id"` - // in:path - // required:true - UserID int64 `json:"user_id"` -} - -// swagger:parameters adminDeleteOrg -type AdminDeleteOrgParams struct { - // in:path - // required:true - OrgID int64 `json:"org_id"` -} - -// swagger:parameters adminGetOrgUsers -type AdminGetOrgUsersParams struct { - // in:path - // required:true - OrgID int64 `json:"org_id"` -} - -// swagger:parameters adminUpdateOrg -type AdminUpdateOrgParams struct { - // in:body - // required:true - Body dtos.UpdateOrgForm `json:"body"` - // in:path - // required:true - OrgID int64 `json:"org_id"` -} - -// swagger:parameters adminAddOrgUser -type AdminAddOrgUserParams struct { - // in:body - // required:true - Body models.AddOrgUserCommand `json:"body"` - // in:path - // required:true - OrgID int64 `json:"org_id"` -} - -// swagger:parameters getOrgByName -type OrgNameParam struct { - // in:path - // required:true - OrgName string `json:"org_name"` -} - -// swagger:parameters createOrg -type CreateOrgParam struct { - // in:body - // required:true - Body models.CreateOrgCommand `json:"body"` -} - -// swagger:parameters searchOrg -type SearchOrgParams struct { - // in:query - // required:false - // default: 1 - Page int `json:"page"` - // Number of items per page - // The totalCount field in the response can be used for pagination list E.g. if totalCount is equal to 100 teams and the perpage parameter is set to 10 then there are 10 pages of teams. - // in:query - // required:false - // default: 1000 - PerPage int `json:"perpage"` - Name string `json:"name"` - // If set it will return results where the query value is contained in the name field. Query values with spaces need to be URL encoded. - // required:false - Query string `json:"query"` -} - -// swagger:parameters updateOrgQuota -type UpdateOrgQuotaParam struct { - // in:body - // required:true - Body models.UpdateOrgQuotaCmd `json:"body"` - // in:path - // required:true - QuotaTarget string `json:"quota_target"` - // in:path - // required:true - OrgID int64 `json:"org_id"` -} - -// swagger:response createOrgResponse -type CreateOrgResponse struct { - // The response message - // in: body - Body struct { - // ID Identifier of the created org. - // required: true - // example: 65 - OrgID int64 `json:"orgId"` - - // Message Message of the created org. - // required: true - // example: Data source added - Message string `json:"message"` - } `json:"body"` -} - -// swagger:response searchOrgResponse -type SearchOrgResponse struct { - // The response message - // in: body - Body []*models.OrgDTO `json:"body"` -} diff --git a/pkg/api/docs/definitions/playlists.go b/pkg/api/docs/definitions/playlists.go deleted file mode 100644 index 03989c4d153..00000000000 --- a/pkg/api/docs/definitions/playlists.go +++ /dev/null @@ -1,177 +0,0 @@ -package definitions - -import ( - "github.com/grafana/grafana/pkg/api/dtos" - "github.com/grafana/grafana/pkg/services/playlist" -) - -// swagger:route GET /playlists playlists searchPlaylists -// -// Get playlists. -// -// Responses: -// 200: searchPlaylistsResponse -// 500: internalServerError - -// swagger:route GET /playlists/{uid} playlists getPlaylist -// -// Get playlist by UID. -// -// Responses: -// 200: getPlaylistResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route GET /playlists/{uid}/items playlists getPlaylistItems -// -// Get playlist items. -// -// Responses: -// 200: getPlaylistItemsResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route GET /playlists/{uid}/dashboards playlists getPlaylistDashboards -// -// Get playlist dashboards. -// -// Responses: -// 200: getPlaylistDashboardsResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route DELETE /playlists/{uid} playlists deletePlaylist -// -// Delete pllaylist. -// -// Responses: -// 200: okResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route PUT /playlists/{uid} playlists updatePlaylist -// -// Update playlist. -// -// Responses: -// 200: updatePlaylistResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route POST /playlists playlists createPlaylist -// -// Create playlist. -// -// Responses: -// 200: createPlaylistResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:parameters searchPlaylists -type SearchPlaylistsParams struct { - // in:query - // required:false - Query string `json:"query"` - // in:limit - // required:false - Limit int `json:"limit"` -} - -// swagger:parameters getPlaylist -type GetPlaylistParams struct { - // in:path - // required:true - UID string `json:"uid"` -} - -// swagger:parameters getPlaylistItems -type GetPlaylistItemsParams struct { - // in:path - // required:true - UID string `json:"uid"` -} - -// swagger:parameters getPlaylistDashboards -type GetPlaylistDashboardsParams struct { - // in:path - // required:true - UID string `json:"uid"` -} - -// swagger:parameters deletePlaylist -type DeletePlaylistParams struct { - // in:path - // required:true - UID string `json:"uid"` -} - -// swagger:parameters updatePlaylist -type UpdatePlaylistParams struct { - // in:body - // required:true - Body playlist.UpdatePlaylistCommand - // in:path - // required:true - UID string `json:"uid"` -} - -// swagger:parameters createPlaylist -type CreatePlaylistParams struct { - // in:body - // required:true - Body playlist.CreatePlaylistCommand -} - -// swagger:response searchPlaylistsResponse -type SearchPlaylistsResponse struct { - // The response message - // in: body - Body playlist.Playlists `json:"body"` -} - -// swagger:response getPlaylistResponse -type GetPlaylistResponse struct { - // The response message - // in: body - Body *playlist.PlaylistDTO `json:"body"` -} - -// swagger:response getPlaylistItemsResponse -type GetPlaylistItemsResponse struct { - // The response message - // in: body - Body []playlist.PlaylistItemDTO `json:"body"` -} - -// swagger:response getPlaylistDashboardsResponse -type GetPlaylistDashboardsResponse struct { - // The response message - // in: body - Body dtos.PlaylistDashboardsSlice `json:"body"` -} - -// swagger:response updatePlaylistResponse -type UpdatePlaylistResponseResponse struct { - // The response message - // in: body - Body *playlist.PlaylistDTO `json:"body"` -} - -// swagger:response createPlaylistResponse -type CreatePlaylistResponse struct { - // The response message - // in: body - Body *playlist.Playlist `json:"body"` -} diff --git a/pkg/api/docs/definitions/query_history.go b/pkg/api/docs/definitions/query_history.go deleted file mode 100644 index 12fc438477a..00000000000 --- a/pkg/api/docs/definitions/query_history.go +++ /dev/null @@ -1,179 +0,0 @@ -package definitions - -import ( - "github.com/grafana/grafana/pkg/services/queryhistory" -) - -// swagger:route GET /query-history query_history searchQueries -// -// Query history search. -// -// Returns a list of queries in the query history that matches the search criteria. -// Query history search supports pagination. Use the `limit` parameter to control the maximum number of queries returned; the default limit is 100. -// You can also use the `page` query parameter to fetch queries from any page other than the first one. -// -// Responses: -// 200: getQueryHistorySearchResponse -// 401: unauthorisedError -// 500: internalServerError - -// swagger:route POST /query-history query_history createQuery -// -// Add query to query history. -// -// Adds new query to query history. -// -// Responses: -// 200: getQueryHistoryResponse -// 400: badRequestError -// 401: unauthorisedError -// 500: internalServerError - -// swagger:route POST /query-history/star/{query_history_uid} query_history starQuery -// -// Add star to query in query history. -// -// Adds star to query in query history as specified by the UID. -// -// Responses: -// 200: getQueryHistoryResponse -// 401: unauthorisedError -// 500: internalServerError - -// swagger:route POST /query-history/migrate query_history migrateQueries -// -// Migrate queries to query history. -// -// Adds multiple queries to query history. -// -// Responses: -// 200: getQueryHistoryMigrationResponse -// 400: badRequestError -// 401: unauthorisedError -// 500: internalServerError - -// swagger:route PATCH /query-history/{query_history_uid} query_history patchQueryComment -// -// Update comment for query in query history. -// -// Updates comment for query in query history as specified by the UID. -// -// Responses: -// 200: getQueryHistoryResponse -// 400: badRequestError -// 401: unauthorisedError -// 500: internalServerError - -// swagger:route DELETE /query-history/{query_history_uid} query_history deleteQuery -// -// Delete query in query history. -// -// Deletes an existing query in query history as specified by the UID. This operation cannot be reverted. -// -// Responses: -// 200: getQueryHistoryDeleteQueryResponse -// 401: unauthorisedError -// 500: internalServerError - -// swagger:route DELETE /query-history/star/{query_history_uid} query_history unstarQuery -// -// Remove star to query in query history. -// -// Removes star from query in query history as specified by the UID. -// -// Responses: -// 200: getQueryHistoryResponse -// 401: unauthorisedError -// 500: internalServerError - -// swagger:parameters starQuery patchQueryComment deleteQuery unstarQuery -type QueryHistoryByUID struct { - // in:path - // required:true - UID string `json:"query_history_uid"` -} - -// swagger:parameters searchQueries -type SearchQueriesParams struct { - // List of data source UIDs to search for - // in:query - // required: false - // type: array - // collectionFormat: multi - DatasourceUid []string `json:"datasourceUid"` - // Text inside query or comments that is searched for - // in:query - // required: false - SearchString string `json:"searchString"` - // Flag indicating if only starred queries should be returned - // in:query - // required: false - OnlyStarred bool `json:"onlyStarred"` - // Sort method - // in:query - // required: false - // default: time-desc - // Enum: time-desc,time-asc - Sort string `json:"sort"` - // Use this parameter to access hits beyond limit. Numbering starts at 1. limit param acts as page size. - // in:query - // required: false - Page int `json:"page"` - // Limit the number of returned results - // in:query - // required: false - Limit int `json:"limit"` - // From range for the query history search - // in:query - // required: false - From int64 `json:"from"` - // To range for the query history search - // in:query - // required: false - To int64 `json:"to"` -} - -// swagger:parameters createQuery -type CreateQueryParams struct { - // in:body - // required:true - Body queryhistory.CreateQueryInQueryHistoryCommand `json:"body"` -} - -// swagger:parameters patchQueryComment -type PatchQueryCommentParams struct { - // in:body - // required:true - Body queryhistory.PatchQueryCommentInQueryHistoryCommand `json:"body"` -} - -// swagger:parameters migrateQueries -type MigrateQueriesParams struct { - // in:body - // required:true - Body queryhistory.MigrateQueriesToQueryHistoryCommand `json:"body"` -} - -//swagger:response getQueryHistorySearchResponse -type GetQueryHistorySearchResponse struct { - // in: body - Body queryhistory.QueryHistorySearchResponse `json:"body"` -} - -// swagger:response getQueryHistoryResponse -type GetQueryHistoryResponse struct { - // in: body - Body queryhistory.QueryHistoryResponse `json:"body"` -} - -// swagger:response getQueryHistoryDeleteQueryResponse -type GetQueryHistoryDeleteQueryResponse struct { - // in: body - Body queryhistory.QueryHistoryDeleteQueryResponse `json:"body"` -} - -// swagger:response getQueryHistoryMigrationResponse -type GetQueryHistoryMigrationResponse struct { - // in: body - Body queryhistory.QueryHistoryMigrationResponse `json:"body"` -} diff --git a/pkg/api/docs/definitions/search.go b/pkg/api/docs/definitions/search.go deleted file mode 100644 index 4bb937aa98f..00000000000 --- a/pkg/api/docs/definitions/search.go +++ /dev/null @@ -1,94 +0,0 @@ -package definitions - -import "github.com/grafana/grafana/pkg/models" - -// swagger:route GET /search/sorting search searchSorting -// -// List search sorting options -// -// Responses: -// 200: searchSortingResponse -// 401: unauthorisedError - -// swagger:route GET /search search search -// -// Responses: -// 200: searchResponse -// 401: unauthorisedError -// 422: unprocessableEntityError -// 500: internalServerError - -// swagger:parameters search -type SearchParams struct { - // Search Query - // in:query - // required: false - Query string `json:"query"` - // List of tags to search for - // in:query - // required: false - // type: array - // collectionFormat: multi - Tag []string `json:"tag"` - // Type to search for, dash-folder or dash-db - // in:query - // required: false - // Description: - // * `dash-folder` - Search for folder - // * `dash-db` - Seatch for dashboard - // Enum: dash-folder,dash-db - Type string `json:"type"` - // List of dashboard id’s to search for - // in:query - // required: false - DashboardIds []int64 `json:"dashboardIds"` - // List of dashboard uid’s to search for - // in:query - // required: false - DashboardUIDs []string `json:"dashboardUIDs"` - // List of folder id’s to search in for dashboards - // in:query - // required: false - FolderIds []int64 `json:"folderIds"` - // Flag indicating if only starred Dashboards should be returned - // in:query - // required: false - Starred bool `json:"starred"` - // Limit the number of returned results (max 5000) - // in:query - // required: false - Limit int64 `json:"limit"` - // Use this parameter to access hits beyond limit. Numbering starts at 1. limit param acts as page size. Only available in Grafana v6.2+. - // in:query - // required: false - Page int64 `json:"page"` - // Set to `Edit` to return dashboards/folders that the user can edit - // in:query - // required: false - // default:View - // Enum: Edit,View - Permission string `json:"permission"` - // Sort method; for listing all the possible sort methods use the search sorting endpoint. - // in:query - // required: false - // default: alpha-asc - // Enum: alpha-asc,alpha-desc - Sort string `json:"sort"` -} - -// swagger:response searchResponse -type SearchResponse struct { - // in: body - Body models.HitList `json:"body"` -} - -// swagger:response searchSortingResponse -type SearchSortingResponse struct { - // in: body - Body struct { - Name string `json:"name"` - DisplayName string `json:"displayName"` - Description string `json:"description"` - Meta string `json:"meta"` - } `json:"body"` -} diff --git a/pkg/api/docs/definitions/service_account_tokens.go b/pkg/api/docs/definitions/service_account_tokens.go deleted file mode 100644 index a7fc74e0134..00000000000 --- a/pkg/api/docs/definitions/service_account_tokens.go +++ /dev/null @@ -1,90 +0,0 @@ -package definitions - -import ( - "github.com/grafana/grafana/pkg/api/dtos" - "github.com/grafana/grafana/pkg/services/serviceaccounts" - "github.com/grafana/grafana/pkg/services/serviceaccounts/api" -) - -// swagger:route GET /serviceaccounts/{serviceAccountId}/tokens service_accounts listTokens -// -// Get service account tokens -// -// Required permissions (See note in the [introduction](https://grafana.com/docs/grafana/latest/developers/http_api/serviceaccount/#service-account-api) for an explanation): -// action: `serviceaccounts:read` scope: `global:serviceaccounts:id:1` (single service account) -// -// Requires basic authentication and that the authenticated user is a Grafana Admin. -// -// Responses: -// 200: listTokensResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route POST /serviceaccounts/{serviceAccountId}/tokens service_accounts createToken -// -// Create service account tokens -// -// Required permissions (See note in the [introduction](https://grafana.com/docs/grafana/latest/developers/http_api/serviceaccount/#service-account-api) for an explanation): -// action: `serviceaccounts:write` scope: `serviceaccounts:id:1` (single service account) -// -// Responses: -// 200: createTokenResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 409: conflictError -// 500: internalServerError - -// swagger:route DELETE /serviceaccounts/{serviceAccountId}/tokens/{tokenId} service_accounts deleteToken -// -// Delete service account tokens -// -// Required permissions (See note in the [introduction](https://grafana.com/docs/grafana/latest/developers/http_api/serviceaccount/#service-account-api) for an explanation): -// action: `serviceaccounts:write` scope: `serviceaccounts:id:1` (single service account) -// -// Requires basic authentication and that the authenticated user is a Grafana Admin. -// -// Responses: -// 200: okResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:parameters listTokens -type ListTokensParams struct { - // in:path - ServiceAccountId int64 `json:"serviceAccountId"` -} - -// swagger:parameters createToken -type CreateTokenParams struct { - // in:path - ServiceAccountId int64 `json:"serviceAccountId"` - // in:body - Body serviceaccounts.AddServiceAccountTokenCommand -} - -// swagger:parameters deleteToken -type DeleteTokenParams struct { - // in:path - TokenId int64 `json:"tokenId"` - // in:path - ServiceAccountId int64 `json:"serviceAccountId"` -} - -// swagger:response listTokensResponse -type ListTokensResponse struct { - // in:body - Body *api.TokenDTO -} - -// swagger:response createTokenResponse -type CreateTokenResponse struct { - // in:body - Body *dtos.NewApiKeyResult -} diff --git a/pkg/api/docs/definitions/service_accounts.go b/pkg/api/docs/definitions/service_accounts.go deleted file mode 100644 index 52455fe3569..00000000000 --- a/pkg/api/docs/definitions/service_accounts.go +++ /dev/null @@ -1,154 +0,0 @@ -package definitions - -import "github.com/grafana/grafana/pkg/services/serviceaccounts" - -// swagger:route GET /serviceaccounts/search service_accounts searchOrgServiceAccountsWithPaging -// -// Search service accounts with Paging -// -// Required permissions (See note in the [introduction](https://grafana.com/docs/grafana/latest/developers/http_api/serviceaccount/#service-account-api) for an explanation): -// action: `serviceaccounts:read` scope: `serviceaccounts:*` -// -// Responses: -// 200: searchOrgServiceAccountsWithPagingResponse -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route POST /serviceaccounts service_accounts createServiceAccount -// -// Create service account -// -// Required permissions (See note in the [introduction](https://grafana.com/docs/grafana/latest/developers/http_api/serviceaccount/#service-account-api) for an explanation): -// action: `serviceaccounts:write` scope: `serviceaccounts:*` -// -// Requires basic authentication and that the authenticated user is a Grafana Admin. -// -// Responses: -// 201: createServiceAccountResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route GET /serviceaccounts/{serviceAccountId} service_accounts retrieveServiceAccount -// -// Get single serviceaccount by Id -// -// Required permissions (See note in the [introduction](https://grafana.com/docs/grafana/latest/developers/http_api/serviceaccount/#service-account-api) for an explanation): -// action: `serviceaccounts:read` scope: `serviceaccounts:id:1` (single service account) -// -// Responses: -// 200: retrieveServiceAccountResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route PATCH /serviceaccounts/{serviceAccountId} service_accounts updateServiceAccount -// -// Update service account -// -// Required permissions (See note in the [introduction](https://grafana.com/docs/grafana/latest/developers/http_api/serviceaccount/#service-account-api) for an explanation): -// action: `serviceaccounts:write` scope: `serviceaccounts:id:1` (single service account) -// -// Responses: -// 200: updateServiceAccountResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route DELETE /serviceaccounts/{serviceAccountId} service_accounts deleteServiceAccount -// -// Delete service account -// -// Required permissions (See note in the [introduction](https://grafana.com/docs/grafana/latest/developers/http_api/serviceaccount/#service-account-api) for an explanation): -// action: `serviceaccounts:delete` scope: `serviceaccounts:id:1` (single service account) -// -// Responses: -// 200: okResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:parameters searchOrgServiceAccountsWithPaging -type SearchOrgServiceAccountsWithPagingParams struct { - // in:query - // required:false - Disabled bool `jsson:"disabled"` - // in:query - // required:false - ExpiredTokens bool `json:"expiredTokens"` - // It will return results where the query value is contained in one of the name. - // Query values with spaces need to be URL encoded. - // in:query - // required:false - Query string `json:"query"` - // The default value is 1000. - // in:query - // required:false - PerPage int `json:"perpage"` - // The default value is 1. - // in:query - // required:false - Page int `json:"page"` -} - -// swagger:parameters createServiceAccount -type CreateServiceAccountParams struct { - //in:body - Body serviceaccounts.CreateServiceAccountForm -} - -// swagger:parameters retrieveServiceAccount -type RetrieveServiceAccountParams struct { - // in:path - ServiceAccountId int64 `json:"serviceAccountId"` -} - -// swagger:parameters updateServiceAccount -type UpdateServiceAccountParams struct { - // in:path - ServiceAccountId int64 `json:"serviceAccountId"` - // in:body - Body serviceaccounts.UpdateServiceAccountForm -} - -// swagger:parameters deleteServiceAccount -type DeleteServiceAccountParams struct { - // in:path - ServiceAccountId int64 `json:"serviceAccountId"` -} - -// swagger:response searchOrgServiceAccountsWithPagingResponse -type SearchOrgServiceAccountsWithPagingResponse struct { - // in:body - Body *serviceaccounts.SearchServiceAccountsResult -} - -// swagger:response createServiceAccountResponse -type CreateServiceAccountResponse struct { - // in:body - Body *serviceaccounts.ServiceAccountDTO -} - -// swagger:response retrieveServiceAccountResponse -type RetrieveServiceAccountResponse struct { - // in:body - Body *serviceaccounts.ServiceAccountDTO -} - -// swagger:response updateServiceAccountResponse -type UpdateServiceAccountResponse struct { - // in:body - Body struct { - Message string `json:"message"` - ID int64 `json:"id"` - Name string `json:"name"` - ServiceAccount *serviceaccounts.ServiceAccountProfileDTO `json:"serviceaccount"` - } -} diff --git a/pkg/api/docs/definitions/snapshot.go b/pkg/api/docs/definitions/snapshot.go deleted file mode 100644 index 62cd890fc3a..00000000000 --- a/pkg/api/docs/definitions/snapshot.go +++ /dev/null @@ -1,135 +0,0 @@ -package definitions - -import ( - "github.com/grafana/grafana/pkg/services/dashboardsnapshots" -) - -// swagger:route POST /snapshots snapshots createSnapshot -// -// When creating a snapshot using the API, you have to provide the full dashboard payload including the snapshot data. This endpoint is designed for the Grafana UI. -// -// Snapshot public mode should be enabled or authentication is required. -// -// Responses: -// 200: createSnapshotResponse -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route GET /dashboard/snapshots snapshots getSnapshots -// -// List snapshots. -// -// Responses: -// 200: getSnapshotsResponse -// 500: internalServerError - -// swagger:route GET /snapshots/{key} snapshots getSnapshotByKey -// -// Get Snapshot by Key. -// -// Responses: -// 200: snapshotResponse -// 404: notFoundError -// 500: internalServerError - -// swagger:route DELETE /snapshots/{key} snapshots deleteSnapshotByKey -// -// Delete Snapshot by Key. -// -// Responses: -// 200: okResponse -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route GET /snapshots-delete/{deleteKey} snapshots deleteSnapshotByDeleteKey -// -// Delete Snapshot by deleteKey. -// -// Snapshot public mode should be enabled or authentication is required. -// -// Responses: -// 200: okResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route GET /snapshot/shared-options snapshots getSnapshotSharingOptions -// -// Get snapshot sharing settings. -// -// Responses: -// 200: getSnapshotSharingOptionsResponse -// 401: unauthorisedError - -// swagger:parameters createSnapshot -type CreateSnapshotParams struct { - // in:body - // required:true - Body dashboardsnapshots.CreateDashboardSnapshotCommand `json:"body"` -} - -// swagger:parameters getSnapshots -type GetSnapshotsParams struct { - // Search Query - // in:query - Query string `json:"query"` - // Limit the number of returned results - // in:query - // default:1000 - Limit int64 `json:"limit"` -} - -// swagger:parameters getSnapshotByKey -type SnapshotByKeyParams struct { - // in:path - Key string `json:"key"` -} - -// swagger:parameters deleteSnapshotByKey -type DeleteSnapshotByKeyParams struct { - // in:path - Key string `json:"key"` -} - -// swagger:parameters deleteSnapshotByDeleteKey -type DeleteSnapshotByDeleteKeyParams struct { - // in:path - DeleteKey string `json:"deleteKey"` -} - -// swagger:response createSnapshotResponse -type CreateSnapshotResponse struct { - // in:body - Body struct { - // Unique key - Key string `json:"key"` - // Unique key used to delete the snapshot. It is different from the key so that only the creator can delete the snapshot. - DeleteKey string `json:"deleteKey"` - URL string `json:"url"` - DeleteUrl string `json:"deleteUrl"` - // Snapshot id - ID int64 `json:"id"` - } `json:"body"` -} - -// swagger:response getSnapshotsResponse -type GetSnapshotsResponse struct { - // in:body - Body []*dashboardsnapshots.DashboardSnapshotDTO `json:"body"` -} - -// swagger:response snapshotResponse -type SnapshotResponse DashboardResponse - -// swagger:response getSnapshotSharingOptionsResponse -type GetSnapshotSharingOptionsResponse struct { - // in:body - Body struct { - ExternalSnapshotURL string `json:"externalSnapshotURL"` - ExternalSnapshotName string `json:"externalSnapshotName"` - ExternalEnabled bool `json:"externalEnabled"` - } `json:"body"` -} diff --git a/pkg/api/docs/definitions/teams.go b/pkg/api/docs/definitions/teams.go deleted file mode 100644 index 73224e73848..00000000000 --- a/pkg/api/docs/definitions/teams.go +++ /dev/null @@ -1,261 +0,0 @@ -package definitions - -import ( - "github.com/grafana/grafana/pkg/api/dtos" - "github.com/grafana/grafana/pkg/models" -) - -// swagger:route GET /teams/search teams searchTeams -// -// Team Search With Paging. -// -// Responses: -// 200: searchTeamsResponse -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route POST /teams teams createTeam -// -// Add Team. -// -// Responses: -// 200: createTeamResponse -// 401: unauthorisedError -// 403: forbiddenError -// 409: conflictError -// 500: internalServerError - -// swagger:route GET /teams/{team_id} teams getTeam -// -// Get Team By ID. -// -// Responses: -// 200: getTeamResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route PUT /teams/{team_id} teams updateTeam -// -// Update Team. -// -// Responses: -// 200: okResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 409: conflictError -// 500: internalServerError - -// swagger:route DELETE /teams/{team_id} teams deleteTeamByID -// -// Delete Team By ID. -// -// Responses: -// 200: okResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route GET /teams/{team_id}/members teams getTeamMembers -// -// Get Team Members. -// -// Responses: -// 200: getTeamMembersResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route POST /teams/{team_id}/members teams addTeamMember -// -// Add Team Member. -// -// Responses: -// 200: okResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route PUT /teams/{team_id}/members/{user_id} teams updateTeamMember -// -// Update Team Member. -// -// Responses: -// 200: okResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route DELETE /teams/{team_id}/members/{user_id} teams removeTeamMember -// -// Remove Member From Team. -// -// Responses: -// 200: okResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route GET /teams/{team_id}/preferences teams getTeamPreferences -// -// Get Team Preferences. -// -// Responses: -// 200: getPreferencesResponse -// 401: unauthorisedError -// 500: internalServerError - -// swagger:route PUT /teams/{team_id}/preferences teams updateTeamPreferences -// -// Update Team Preferences. -// -// Responses: -// 200: okResponse -// 400: badRequestError -// 401: unauthorisedError -// 500: internalServerError - -// swagger:parameters updateTeamPreferences -type UpdateTeamPreferencesParams struct { - // in:path - // required:true - TeamID string `json:"team_id"` - // in:body - // required:true - Body dtos.UpdatePrefsCmd `json:"body"` -} - -// swagger:parameters getTeam -type GetTeamParams struct { - // in:path - // required:true - TeamID string `json:"team_id"` -} - -// swagger:parameters deleteTeamByID -type DeleteTeamByIDParams struct { - // in:path - // required:true - TeamID string `json:"team_id"` -} - -// swagger:parameters getTeamMembers -type GetTeamMembersParams struct { - // in:path - // required:true - TeamID string `json:"team_id"` -} - -// swagger:parameters getTeamPreferences -type GetTeamPreferencesParams struct { - // in:path - // required:true - TeamID string `json:"team_id"` -} - -// swagger:parameters removeTeamMember -type RemoveTeamMemberParams struct { - // in:path - // required:true - TeamID string `json:"team_id"` - // in:path - // required:true - UserID int64 `json:"user_id"` -} - -// swagger:parameters searchTeams -type SearchTeamsParams struct { - // in:query - // required:false - // default: 1 - Page int `json:"page"` - // Number of items per page - // The totalCount field in the response can be used for pagination list E.g. if totalCount is equal to 100 teams and the perpage parameter is set to 10 then there are 10 pages of teams. - // in:query - // required:false - // default: 1000 - PerPage int `json:"perpage"` - Name string `json:"name"` - // If set it will return results where the query value is contained in the name field. Query values with spaces need to be URL encoded. - // required:false - Query string `json:"query"` -} - -// swagger:parameters createTeam -type CreateTeamParams struct { - // in:body - // required:true - Body models.CreateTeamCommand `json:"body"` -} - -// swagger:parameters updateTeam -type UpdateTeamParams struct { - // in:body - // required:true - Body models.UpdateTeamCommand `json:"body"` - // in:path - // required:true - TeamID string `json:"team_id"` -} - -// swagger:parameters addTeamMember -type AddTeamMemberParams struct { - // in:body - // required:true - Body models.AddTeamMemberCommand `json:"body"` - // in:path - // required:true - TeamID string `json:"team_id"` -} - -// swagger:parameters updateTeamMember -type UpdateTeamMember struct { - // in:body - // required:true - Body models.UpdateTeamMemberCommand `json:"body"` - // in:path - // required:true - TeamID string `json:"team_id"` - // in:path - // required:true - UserID int64 `json:"user_id"` -} - -// swagger:response searchTeamsResponse -type SearchTeamsResponse struct { - // The response message - // in: body - Body models.SearchTeamQueryResult `json:"body"` -} - -// swagger:response getTeamResponse -type GetTeamResponse struct { - // The response message - // in: body - Body *models.TeamDTO `json:"body"` -} - -// swagger:response createTeamResponse -type CreateTeamResponse struct { - // The response message - // in: body - Body struct { - TeamId int64 `json:"teamId"` - Message string `json:"message"` - } `json:"body"` -} - -// swagger:response getTeamMembersResponse -type GetTeamMembersResponse struct { - // The response message - // in: body - Body []*models.TeamMemberDTO `json:"body"` -} diff --git a/pkg/api/docs/definitions/user.go b/pkg/api/docs/definitions/user.go deleted file mode 100644 index 9a516678d43..00000000000 --- a/pkg/api/docs/definitions/user.go +++ /dev/null @@ -1,223 +0,0 @@ -package definitions - -import "github.com/grafana/grafana/pkg/models" - -// swagger:route GET /user signed_in_user getSignedInUser -// -// Get signed in User. -// -// Responses: -// 200: userResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route PUT /user signed_in_user updateSignedInUser -// -// Update signed in User. -// -// Responses: -// 200: userResponse -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route POST /user/using/{org_id} signed_in_user userSetUsingOrg -// -// Switch user context for signed in user. -// -// Switch user context to the given organization. -// -// Responses: -// 200: okResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route GET /user/orgs signed_in_user getSignedInUserOrgList -// -// Organizations of the actual User. -// -// Return a list of all organizations of the current user. -// -// Security: -// - basic: -// -// Responses: -// 200: getUserOrgListResponse -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route GET /user/teams signed_in_user getSignedInUserTeamList -// -// Teams that the actual User is member of. -// -// Return a list of all teams that the current user is member of. -// -// Responses: -// 200: getUserOrgListResponse -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route POST /user/stars/dashboard/{dashboard_id} signed_in_user starDashboard -// -// Star a dashboard. -// -// Stars the given Dashboard for the actual user. -// -// Responses: -// 200: okResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route DELETE /user/stars/dashboard/{dashboard_id} signed_in_user unstarDashboard -// -// Unstar a dashboard. -// -// Deletes the starring of the given Dashboard for the actual user. -// -// Responses: -// 200: okResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route PUT /user/password signed_in_user changeUserPassword -// -// Change Password. -// -// Changes the password for the user. -// -// Security: -// - basic: -// -// Responses: -// 200: okResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route GET /user/quotas signed_in_user getUserQuotas -// -// Fetch user quota. -// -// Responses: -// 200: getQuotaResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route PUT /user/helpflags/{flag_id} signed_in_user setHelpFlag -// -// Set user help flag. -// -// Responses: -// 200: helpFlagResponse -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route GET /user/helpflags/clear signed_in_user clearHelpFlags -// -// Clear user help flag. -// -// Responses: -// 200: helpFlagResponse -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route GET /user/auth-tokens signed_in_user getSignedInUserAuthTokens -// -// Auth tokens of the actual User. -// -// Return a list of all auth tokens (devices) that the actual user currently have logged in from. -// -// Responses: -// 200: getAuthTokensResponse -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route POST /user/revoke-auth-token signed_in_user revokeSignedInAuthToken -// -// Revoke an auth token of the actual User. -// -// Revokes the given auth token (device) for the actual user. User of issued auth token (device) will no longer be logged in and will be required to authenticate again upon next activity. -// -// Responses: -// 200: okResponse -// 400: badRequestError -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:parameters updateSignedInUser -type UpdateSignedInUserParams struct { - // To change the email, name, login, theme, provide another one. - // in:body - // required:true - Body models.UpdateUserCommand `json:"body"` -} - -// swagger:parameters userSetUsingOrg -type UserSetUsingOrgParams struct { - // in:path - // required:true - OrgID int64 `json:"org_id"` -} - -// swagger:parameters starDashboard -type StarDashboardParams struct { - // in:path - // required:true - DashboardID string `json:"dashboard_id"` -} - -// swagger:parameters unstarDashboard -type UnstarDashboardParams struct { - // in:path - // required:true - DashboardID string `json:"dashboard_id"` -} - -// swagger:parameters setHelpFlag -type SetHelpFlagParams struct { - // in:path - // required:true - FlagID string `json:"flag_id"` -} - -// swagger:parameters changeUserPassword -type ChangeUserPasswordParams struct { - // To change the email, name, login, theme, provide another one. - // in:body - // required:true - Body models.ChangeUserPasswordCommand `json:"body"` -} - -// swagger:parameters revokeSignedInAuthToken -type RevokeSignedINAuthTokenCmdParams struct { - // in:body - // required:true - Body models.RevokeAuthTokenCmd `json:"body"` -} - -// swagger:response helpFlagResponse -type HelpFlagResponse struct { - // The response message - // in: body - Body struct { - HelpFlags1 int64 `json:"helpFlags1"` - Message string `json:"message"` - } `json:"body"` -} diff --git a/pkg/api/docs/definitions/user_preferences.go b/pkg/api/docs/definitions/user_preferences.go deleted file mode 100644 index 4867c3d77c7..00000000000 --- a/pkg/api/docs/definitions/user_preferences.go +++ /dev/null @@ -1,54 +0,0 @@ -package definitions - -import "github.com/grafana/grafana/pkg/api/dtos" - -// swagger:route GET /user/preferences user_preferences getUserPreferences -// -// Get user preferences. -// -// Responses: -// 200: getPreferencesResponse -// 401: unauthorisedError -// 500: internalServerError - -// swagger:route PUT /user/preferences user_preferences updateUserPreferences -// -// Update user preferences. -// -// Omitting a key (`theme`, `homeDashboardId`, `timezone`) will cause the current value to be replaced with the system default value. -// -// Responses: -// 200: okResponse -// 400: badRequestError -// 401: unauthorisedError -// 500: internalServerError - -// swagger:route PATCH /user/preferences user_preferences patchUserPreferences -// -// Patch user preferences. -// -// Responses: -// 200: okResponse -// 400: badRequestError -// 401: unauthorisedError -// 500: internalServerError - -// swagger:parameters updateUserPreferences updateOrgPreferences updateTeamPreferences -type UpdateUserPreferencesParam struct { - // in:body - // required:true - Body dtos.UpdatePrefsCmd `json:"body"` -} - -// swagger:response getPreferencesResponse -type GetPreferencesResponse struct { - // in:body - Body dtos.Prefs `json:"body"` -} - -// swagger:parameters patchUserPreferences patchOrgPreferences patchTeamPreferences -type PatchUserPreferencesParam struct { - // in:body - // required:true - Body dtos.PatchPrefsCmd `json:"body"` -} diff --git a/pkg/api/docs/definitions/users.go b/pkg/api/docs/definitions/users.go deleted file mode 100644 index a18ebe0dc89..00000000000 --- a/pkg/api/docs/definitions/users.go +++ /dev/null @@ -1,190 +0,0 @@ -package definitions - -import ( - "github.com/grafana/grafana/pkg/models" -) - -// swagger:route GET /users users searchUsers -// -// Get users. -// -// Returns all users that the authenticated user has permission to view, admin permission required. -// -// Responses: -// 200: searchUsersResponse -// 401: unauthorisedError -// 403: forbiddenError -// 500: internalServerError - -// swagger:route GET /users/search users searchUsersWithPaging -// -// Get users with paging. -// -// Responses: -// 200: searchUsersResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route GET /users/{user_id} users getUserByID -// -// Get user by id. -// -// Responses: -// 200: userResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route GET /users/lookup users getUserByLoginOrEmail -// -// Get user by login or email. -// -// Responses: -// 200: userResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route PUT /users/{user_id} users updateUser -// -// Update user. -// -// Update the user identified by id. -// -// Responses: -// 200: userResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route GET /users/{user_id}/orgs users getUserOrgList -// -// Get organizations for user. -// -// Get organizations for user identified by id. -// -// Responses: -// 200: getUserOrgListResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:route GET /users/{user_id}/teams users getUserTeams -// -// Get teams for user. -// -// Get teams for user identified by id. -// -// Responses: -// 200: getUserTeamsResponse -// 401: unauthorisedError -// 403: forbiddenError -// 404: notFoundError -// 500: internalServerError - -// swagger:parameters searchUsers -type SearchUsersParams struct { - // Limit the maximum number of users to return per page - // in:query - // required:false - // default:1000 - Limit int64 `json:"perpage"` - // Page index for starting fetching users - // in:query - // required:false - // default:1 - Page int64 `json:"page"` -} - -// swagger:parameters searchUsersWithPaging - -type SearchUsersWithPagingParams struct { - // Limit the maximum number of users to return per page - // in:query - // required:false - // default:1000 - Limit int64 `json:"perpage"` - // Page index for starting fetching users - // in:query - // required:false - // default:1 - Page int64 `json:"page"` - // Query allows return results where the query value is contained in one of the name, login or email fields. Query values with spaces need to be URL encoded e.g. query=Jane%20Doe - // in:query - // required:false - Query string `json:"query"` -} - -// swagger:parameters getUserByID -type GetUserByIDParams struct { - // in:path - // required:true - UserID int64 `json:"user_id"` -} - -// swagger:parameters getUserOrgList -type GetUserOrgListParams struct { - // in:path - // required:true - UserID int64 `json:"user_id"` -} - -// swagger:parameters getUserTeams -type GetUserTeamsParams struct { - // in:path - // required:true - UserID int64 `json:"user_id"` -} - -// swagger:parameters getUserByLoginOrEmail -type GetUserByLoginOrEmailParams struct { - // loginOrEmail of the user - // in:query - // required:true - LoginOrEmail string `json:"loginOrEmail"` -} - -// swagger:parameters updateUser -type UpdateUserParams struct { - // To change the email, name, login, theme, provide another one. - // in:body - // required:true - Body models.UpdateUserCommand `json:"body"` - // in:path - // required:true - UserID int64 `json:"user_id"` -} - -// swagger:response searchUsersResponse -type SearchUsersResponse struct { - // The response message - // in: body - Body models.SearchUserQueryResult `json:"body"` -} - -// swagger:response userResponse -type UserResponse struct { - // The response message - // in: body - Body models.UserProfileDTO `json:"body"` -} - -// swagger:response getUserOrgListResponse -type GetUserOrgListResponse struct { - // The response message - // in: body - Body []*models.UserOrgDTO `json:"body"` -} - -// swagger:response getUserTeamsResponse -type GetUserTeamsResponse struct { - // The response message - // in: body - Body []*models.TeamDTO `json:"body"` -} diff --git a/pkg/api/folder.go b/pkg/api/folder.go index 42fabcbba74..5ba54de4fe0 100644 --- a/pkg/api/folder.go +++ b/pkg/api/folder.go @@ -18,6 +18,17 @@ import ( "github.com/grafana/grafana/pkg/web" ) +// swagger:route GET /folders folders getFolders +// +// Get all folders. +// +// Returns all folders that the authenticated user has permission to view. +// +// Responses: +// 200: getFoldersResponse +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) GetFolders(c *models.ReqContext) response.Response { folders, err := hs.folderService.GetFolders(c.Req.Context(), c.SignedInUser, c.OrgId, c.QueryInt64("limit"), c.QueryInt64("page")) @@ -46,6 +57,16 @@ func (hs *HTTPServer) GetFolders(c *models.ReqContext) response.Response { return response.JSON(http.StatusOK, result) } +// swagger:route GET /folders/{folder_uid} folders getFolderByUID +// +// Get folder by uid. +// +// Responses: +// 200: folderResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) GetFolderByUID(c *models.ReqContext) response.Response { folder, err := hs.folderService.GetFolderByUID(c.Req.Context(), c.SignedInUser, c.OrgId, web.Params(c.Req)[":uid"]) if err != nil { @@ -56,6 +77,18 @@ func (hs *HTTPServer) GetFolderByUID(c *models.ReqContext) response.Response { return response.JSON(http.StatusOK, hs.toFolderDto(c, g, folder)) } +// swagger:route GET /folders/id/{folder_id} folders getFolderByID +// +// Get folder by id. +// +// Returns the folder identified by id. +// +// Responses: +// 200: folderResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) GetFolderByID(c *models.ReqContext) response.Response { id, err := strconv.ParseInt(web.Params(c.Req)[":id"], 10, 64) if err != nil { @@ -70,6 +103,17 @@ func (hs *HTTPServer) GetFolderByID(c *models.ReqContext) response.Response { return response.JSON(http.StatusOK, hs.toFolderDto(c, g, folder)) } +// swagger:route POST /folders folders createFolder +// +// Create folder. +// +// Responses: +// 200: folderResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 409: conflictError +// 500: internalServerError func (hs *HTTPServer) CreateFolder(c *models.ReqContext) response.Response { cmd := models.CreateFolderCommand{} if err := web.Bind(c.Req, &cmd); err != nil { @@ -92,6 +136,18 @@ func (hs *HTTPServer) CreateFolder(c *models.ReqContext) response.Response { return response.JSON(http.StatusOK, hs.toFolderDto(c, g, folder)) } +// swagger:route PUT /folders/{folder_uid} folders updateFolder +// +// Update folder. +// +// Responses: +// 200: folderResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 409: conflictError +// 500: internalServerError func (hs *HTTPServer) UpdateFolder(c *models.ReqContext) response.Response { cmd := models.UpdateFolderCommand{} if err := web.Bind(c.Req, &cmd); err != nil { @@ -114,6 +170,19 @@ func (hs *HTTPServer) UpdateFolder(c *models.ReqContext) response.Response { return response.JSON(http.StatusOK, hs.toFolderDto(c, g, cmd.Result)) } +// swagger:route DELETE /folders/{folder_uid} folders deleteFolder +// +// Delete folder. +// +// Deletes an existing folder identified by UID along with all dashboards (and their alerts) stored in the folder. This operation cannot be reverted. +// +// Responses: +// 200: deleteFolderResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) DeleteFolder(c *models.ReqContext) response.Response { // temporarily adding this function to HTTPServer, will be removed from HTTPServer when librarypanels featuretoggle is removed err := hs.LibraryElementService.DeleteLibraryElementsInFolder(c.Req.Context(), c.SignedInUser, web.Params(c.Req)[":uid"]) if err != nil { @@ -177,3 +246,101 @@ func (hs *HTTPServer) toFolderDto(c *models.ReqContext, g guardian.DashboardGuar AccessControl: hs.getAccessControlMetadata(c, c.OrgId, dashboards.ScopeFoldersPrefix, folder.Uid), } } + +// swagger:parameters getFolders +type GetFoldersParams struct { + // Limit the maximum number of folders to return + // in:query + // required:false + // default:1000 + Limit int64 `json:"limit"` + // Page index for starting fetching folders + // in:query + // required:false + // default:1 + Page int64 `json:"page"` +} + +// swagger:parameters getFolderByUID +type GetFolderByUIDParams struct { + // in:path + // required:true + FolderUID string `json:"folder_uid"` +} + +// swagger:parameters updateFolder +type UpdateFolderParams struct { + // in:path + // required:true + FolderUID string `json:"folder_uid"` + // To change the unique identifier (uid), provide another one. + // To overwrite an existing folder with newer version, set `overwrite` to `true`. + // Provide the current version to safelly update the folder: if the provided version differs from the stored one the request will fail, unless `overwrite` is `true`. + // + // in:body + // required:true + Body models.UpdateFolderCommand `json:"body"` +} + +// swagger:parameters getFolderByID +type GetFolderByIDParams struct { + // in:path + // required:true + FolderID int64 `json:"folder_id"` +} + +// swagger:parameters createFolder +type CreateFolderParams struct { + // in:body + // required:true + Body models.CreateFolderCommand `json:"body"` +} + +// swagger:parameters deleteFolder +type DeleteFolderParams struct { + // in:path + // required:true + FolderUID string `json:"folder_uid"` + // If `true` any Grafana 8 Alerts under this folder will be deleted. + // Set to `false` so that the request will fail if the folder contains any Grafana 8 Alerts. + // in:query + // required:false + // default:false + ForceDeleteRules bool `json:"forceDeleteRules"` +} + +// swagger:response getFoldersResponse +type GetFoldersResponse struct { + // The response message + // in: body + Body []dtos.FolderSearchHit `json:"body"` +} + +// swagger:response folderResponse +type FolderResponse struct { + // The response message + // in: body + Body dtos.Folder `json:"body"` +} + +// swagger:response deleteFolderResponse +type DeleteFolderResponse struct { + // The response message + // in: body + Body struct { + // ID Identifier of the deleted folder. + // required: true + // example: 65 + ID int64 `json:"id"` + + // Title of the deleted folder. + // required: true + // example: My Folder + Title string `json:"title"` + + // Message Message of the deleted folder. + // required: true + // example: Folder My Folder deleted + Message string `json:"message"` + } `json:"body"` +} diff --git a/pkg/api/folder_permission.go b/pkg/api/folder_permission.go index 8d037cb8838..8df9df46160 100644 --- a/pkg/api/folder_permission.go +++ b/pkg/api/folder_permission.go @@ -15,6 +15,16 @@ import ( "github.com/grafana/grafana/pkg/web" ) +// swagger:route GET /folders/{folder_uid}/permissions folder_permissions getFolderPermissionList +// +// Gets all existing permissions for the folder with the given `uid`. +// +// Responses: +// 200: getFolderPermissionListResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) GetFolderPermissionList(c *models.ReqContext) response.Response { folder, err := hs.folderService.GetFolderByUID(c.Req.Context(), c.SignedInUser, c.OrgId, web.Params(c.Req)[":uid"]) @@ -58,6 +68,16 @@ func (hs *HTTPServer) GetFolderPermissionList(c *models.ReqContext) response.Res return response.JSON(http.StatusOK, filteredACLs) } +// swagger:route POST /folders/{folder_uid}/permissions folder_permissions updateFolderPermissions +// +// Updates permissions for a folder. This operation will remove existing permissions if they’re not included in the request. +// +// Responses: +// 200: okResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) UpdateFolderPermissions(c *models.ReqContext) response.Response { apiCmd := dtos.UpdateDashboardACLCommand{} if err := web.Bind(c.Req, &apiCmd); err != nil { @@ -147,3 +167,26 @@ func (hs *HTTPServer) UpdateFolderPermissions(c *models.ReqContext) response.Res "title": folder.Title, }) } + +// swagger:parameters getFolderPermissionList +type GetFolderPermissionListParams struct { + // in:path + // required:true + FolderUID string `json:"folder_uid"` +} + +// swagger:parameters updateFolderPermissions +type UpdateFolderPermissionsParams struct { + // in:path + // required:true + FolderUID string `json:"folder_uid"` + // in:body + // required:true + Body dtos.UpdateDashboardACLCommand +} + +// swagger:response getFolderPermissionListResponse +type GetFolderPermissionsResponse struct { + // in: body + Body []*models.DashboardACLInfoDTO `json:"body"` +} diff --git a/pkg/api/ldap_debug.go b/pkg/api/ldap_debug.go index 6468d9998a8..4db55e18f56 100644 --- a/pkg/api/ldap_debug.go +++ b/pkg/api/ldap_debug.go @@ -101,7 +101,20 @@ func (user *LDAPUserDTO) FetchOrgs(ctx context.Context, sqlstore sqlstore.Store) return nil } -// ReloadLDAPCfg reloads the LDAP configuration +// swagger:route POST /admin/ldap/reload admin_ldap reloadLDAPCfg +// +// Reloads the LDAP configuration. +// +// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `ldap.config:reload`. +// +// Security: +// - basic: +// +// Responses: +// 200: okResponse +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) ReloadLDAPCfg(c *models.ReqContext) response.Response { if !ldap.IsEnabled() { return response.Error(http.StatusBadRequest, "LDAP is not enabled", nil) @@ -114,7 +127,20 @@ func (hs *HTTPServer) ReloadLDAPCfg(c *models.ReqContext) response.Response { return response.Success("LDAP config reloaded") } -// GetLDAPStatus attempts to connect to all the configured LDAP servers and returns information on whenever they're available or not. +// swagger:route GET /admin/ldap/status admin_ldap getLDAPStatus +// +// Attempts to connect to all the configured LDAP servers and returns information on whenever they're available or not. +// +// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `ldap.status:read`. +// +// Security: +// - basic: +// +// Responses: +// 200: okResponse +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) GetLDAPStatus(c *models.ReqContext) response.Response { if !ldap.IsEnabled() { return response.Error(http.StatusBadRequest, "LDAP is not enabled", nil) @@ -154,7 +180,20 @@ func (hs *HTTPServer) GetLDAPStatus(c *models.ReqContext) response.Response { return response.JSON(http.StatusOK, serverDTOs) } -// PostSyncUserWithLDAP enables a single Grafana user to be synchronized against LDAP +// swagger:route POST /admin/ldap/sync/{user_id} admin_ldap postSyncUserWithLDAP +// +// Enables a single Grafana user to be synchronized against LDAP. +// +// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `ldap.user:sync`. +// +// Security: +// - basic: +// +// Responses: +// 200: okResponse +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) PostSyncUserWithLDAP(c *models.ReqContext) response.Response { if !ldap.IsEnabled() { return response.Error(http.StatusBadRequest, "LDAP is not enabled", nil) @@ -236,7 +275,20 @@ func (hs *HTTPServer) PostSyncUserWithLDAP(c *models.ReqContext) response.Respon return response.Success("User synced successfully") } -// GetUserFromLDAP finds an user based on a username in LDAP. This helps illustrate how would the particular user be mapped in Grafana when synced. +// swagger:route GET /admin/ldap/{user_name} admin_ldap getUserFromLDAP +// +// Finds an user based on a username in LDAP. This helps illustrate how would the particular user be mapped in Grafana when synced. +// +// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `ldap.user:read`. +// +// Security: +// - basic: +// +// Responses: +// 200: okResponse +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) GetUserFromLDAP(c *models.ReqContext) response.Response { if !ldap.IsEnabled() { return response.Error(http.StatusBadRequest, "LDAP is not enabled", nil) @@ -323,3 +375,17 @@ func splitName(name string) (string, string) { return names[0], names[1] } } + +// swagger:parameters getUserFromLDAP +type GetLDAPUserParams struct { + // in:path + // required:true + UserName string `json:"user_name"` +} + +// swagger:parameters postSyncUserWithLDAP +type SyncLDAPUserParams struct { + // in:path + // required:true + UserID int64 `json:"user_id"` +} diff --git a/pkg/api/metrics.go b/pkg/api/metrics.go index 7e611bc85c2..de18b1e1baf 100644 --- a/pkg/api/metrics.go +++ b/pkg/api/metrics.go @@ -44,7 +44,20 @@ func (hs *HTTPServer) handleQueryMetricsError(err error) *response.NormalRespons } // QueryMetricsV2 returns query metrics. -// POST /api/ds/query DataSource query w/ expressions +// swagger:route POST /ds/query ds queryMetricsWithExpressions +// +// DataSource query metrics with expressions +// +// If you are running Grafana Enterprise and have Fine-grained access control enabled +// you need to have a permission with action: `datasources:query`. +// +// Responses: +// 200: queryMetricsWithExpressionsRespons +// 207: queryMetricsWithExpressionsRespons +// 401: unauthorisedError +// 400: badRequestError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) QueryMetricsV2(c *models.ReqContext) response.Response { reqDTO := dtos.MetricRequest{} if err := web.Bind(c.Req, &reqDTO); err != nil { @@ -75,3 +88,17 @@ func (hs *HTTPServer) toJsonStreamingResponse(qdr *backend.QueryDataResponse) re return response.JSONStreaming(statusCode, qdr) } + +// swagger:parameters queryMetricsWithExpressions +type QueryMetricsWithExpressionsBodyParams struct { + // in:body + // required:true + Body dtos.MetricRequest `json:"body"` +} + +// swagger:response queryMetricsWithExpressionsRespons +type QueryMetricsWithExpressionsRespons struct { + // The response message + // in: body + Body *backend.QueryDataResponse `json:"body"` +} diff --git a/pkg/api/org.go b/pkg/api/org.go index d5b5c308059..b215cf711ef 100644 --- a/pkg/api/org.go +++ b/pkg/api/org.go @@ -15,12 +15,31 @@ import ( "github.com/grafana/grafana/pkg/web" ) -// GET /api/org +// swagger:route GET /org org getCurrentOrg +// +// Get current Organization +// +// Responses: +// 200: getCurrentOrgResponse +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) GetCurrentOrg(c *models.ReqContext) response.Response { return hs.getOrgHelper(c.Req.Context(), c.OrgId) } -// GET /api/orgs/:orgId +// swagger:route GET /orgs/{org_id} orgs getOrgByID +// +// Get Organization by ID. +// +// Security: +// - basic: +// +// Responses: +// 200: getOrgByIDResponse +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) GetOrgByID(c *models.ReqContext) response.Response { orgId, err := strconv.ParseInt(web.Params(c.Req)[":orgId"], 10, 64) if err != nil { @@ -29,7 +48,18 @@ func (hs *HTTPServer) GetOrgByID(c *models.ReqContext) response.Response { return hs.getOrgHelper(c.Req.Context(), orgId) } -// GET /api/orgs/name/:name +// swagger:route GET /orgs/name/{org_name} orgs getOrgByName +// +// Get Organization by ID. +// +// Security: +// - basic: +// +// Responses: +// 200: getOrgByNameResponse +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) GetOrgByName(c *models.ReqContext) response.Response { org, err := hs.SQLStore.GetOrgByName(web.Params(c.Req)[":name"]) if err != nil { @@ -82,7 +112,18 @@ func (hs *HTTPServer) getOrgHelper(ctx context.Context, orgID int64) response.Re return response.JSON(http.StatusOK, &result) } -// POST /api/orgs +// swagger:route POST /orgs orgs createOrg +// +// Create Organization. +// +// Only works if [users.allow_org_create](https://grafana.com/docs/grafana/latest/administration/configuration/#allow_org_create) is set. +// +// Responses: +// 200: createOrgResponse +// 401: unauthorisedError +// 403: forbiddenError +// 409: conflictError +// 500: internalServerError func (hs *HTTPServer) CreateOrg(c *models.ReqContext) response.Response { cmd := models.CreateOrgCommand{} if err := web.Bind(c.Req, &cmd); err != nil { @@ -109,7 +150,16 @@ func (hs *HTTPServer) CreateOrg(c *models.ReqContext) response.Response { }) } -// PUT /api/org +// swagger:route PUT /org org updateCurrentOrg +// +// Update current Organization. +// +// Responses: +// 200: okResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) UpdateCurrentOrg(c *models.ReqContext) response.Response { form := dtos.UpdateOrgForm{} if err := web.Bind(c.Req, &form); err != nil { @@ -118,7 +168,19 @@ func (hs *HTTPServer) UpdateCurrentOrg(c *models.ReqContext) response.Response { return hs.updateOrgHelper(c.Req.Context(), form, c.OrgId) } -// PUT /api/orgs/:orgId +// swagger:route PUT /orgs/{org_id} orgs updateOrg +// +// Update Organization. +// +// Security: +// - basic: +// +// Responses: +// 200: okResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) UpdateOrg(c *models.ReqContext) response.Response { form := dtos.UpdateOrgForm{} if err := web.Bind(c.Req, &form); err != nil { @@ -143,7 +205,16 @@ func (hs *HTTPServer) updateOrgHelper(ctx context.Context, form dtos.UpdateOrgFo return response.Success("Organization updated") } -// PUT /api/org/address +// swagger:route PUT /org/address org updateCurrentOrgAddress +// +// Update current Organization's address. +// +// Responses: +// 200: okResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) UpdateCurrentOrgAddress(c *models.ReqContext) response.Response { form := dtos.UpdateOrgAddressForm{} if err := web.Bind(c.Req, &form); err != nil { @@ -152,7 +223,16 @@ func (hs *HTTPServer) UpdateCurrentOrgAddress(c *models.ReqContext) response.Res return hs.updateOrgAddressHelper(c.Req.Context(), form, c.OrgId) } -// PUT /api/orgs/:orgId/address +// swagger:route PUT /orgs/{org_id}/address orgs updateOrgAddress +// +// Update Organization's address. +// +// Responses: +// 200: okResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) UpdateOrgAddress(c *models.ReqContext) response.Response { form := dtos.UpdateOrgAddressForm{} if err := web.Bind(c.Req, &form); err != nil { @@ -185,7 +265,20 @@ func (hs *HTTPServer) updateOrgAddressHelper(ctx context.Context, form dtos.Upda return response.Success("Address updated") } -// DELETE /api/orgs/:orgId +// swagger:route DELETE /orgs/{org_id} orgs deleteOrgByID +// +// Delete Organization. +// +// Security: +// - basic: +// +// Responses: +// 200: okResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) DeleteOrgByID(c *models.ReqContext) response.Response { orgID, err := strconv.ParseInt(web.Params(c.Req)[":orgId"], 10, 64) if err != nil { @@ -205,6 +298,19 @@ func (hs *HTTPServer) DeleteOrgByID(c *models.ReqContext) response.Response { return response.Success("Organization deleted") } +// swagger:route GET /orgs orgs searchOrgs +// +// Search all Organizations +// +// Security: +// - basic: +// +// Responses: +// 200: searchOrgsResponse +// 401: unauthorisedError +// 403: forbiddenError +// 409: conflictError +// 500: internalServerError func (hs *HTTPServer) SearchOrgs(c *models.ReqContext) response.Response { perPage := c.QueryInt("perpage") if perPage <= 0 { @@ -226,3 +332,138 @@ func (hs *HTTPServer) SearchOrgs(c *models.ReqContext) response.Response { return response.JSON(http.StatusOK, query.Result) } + +// swagger:parameters updateCurrentOrgAddress +type UpdateCurrentOrgAddressParams struct { + // in:body + // required:true + Body dtos.UpdateOrgAddressForm `json:"body"` +} + +// swagger:parameters updateCurrentOrgUser +type UpdateCurrentOrgUserParams struct { + // in:body + // required:true + Body models.UpdateOrgUserCommand `json:"body"` + // in:path + // required:true + UserID int64 `json:"user_id"` +} + +// swagger:parameters updateCurrentOrg +type UpdateCurrentOrgParams struct { + // in:body + // required:true + Body dtos.UpdateOrgForm `json:"body"` +} + +// swagger:parameters updateOrgAddress +type UpdateOrgAddressParams struct { + // in:body + // required:true + Body dtos.UpdateOrgAddressForm `json:"body"` + // in:path + // required:true + OrgID int64 `json:"org_id"` +} + +// swagger:parameters getOrgByID +type GetOrgByIDParams struct { + // in:path + // required:true + OrgID int64 `json:"org_id"` +} + +// swagger:parameters deleteOrgByID +type DeleteOrgByIDParams struct { + // in:path + // required:true + OrgID int64 `json:"org_id"` +} + +// swagger:parameters updateOrg +type UpdateOrgParams struct { + // in:body + // required:true + Body dtos.UpdateOrgForm `json:"body"` + // in:path + // required:true + OrgID int64 `json:"org_id"` +} + +// swagger:parameters getOrgByName +type GetOrgByNameParams struct { + // in:path + // required:true + OrgName string `json:"org_name"` +} + +// swagger:parameters createOrg +type CreateOrgParams struct { + // in:body + // required:true + Body models.CreateOrgCommand `json:"body"` +} + +// swagger:parameters searchOrgs +type SearchOrgParams struct { + // in:query + // required:false + // default: 1 + Page int `json:"page"` + // Number of items per page + // The totalCount field in the response can be used for pagination list E.g. if totalCount is equal to 100 teams and the perpage parameter is set to 10 then there are 10 pages of teams. + // in:query + // required:false + // default: 1000 + PerPage int `json:"perpage"` + Name string `json:"name"` + // If set it will return results where the query value is contained in the name field. Query values with spaces need to be URL encoded. + // required:false + Query string `json:"query"` +} + +// swagger:response createOrgResponse +type CreateOrgResponse struct { + // The response message + // in: body + Body struct { + // ID Identifier of the created org. + // required: true + // example: 65 + OrgID int64 `json:"orgId"` + + // Message Message of the created org. + // required: true + // example: Data source added + Message string `json:"message"` + } `json:"body"` +} + +// swagger:response searchOrgsResponse +type SearchOrgsResponse struct { + // The response message + // in: body + Body []*models.OrgDTO `json:"body"` +} + +// swagger:response getCurrentOrgResponse +type GetCurrentOrgResponse struct { + // The response message + // in: body + Body models.OrgDetailsDTO `json:"body"` +} + +// swagger:response getOrgByIDResponse +type GetOrgByIDResponse struct { + // The response message + // in: body + Body models.OrgDetailsDTO `json:"body"` +} + +// swagger:response getOrgByNameResponse +type GetOrgByNameResponse struct { + // The response message + // in: body + Body models.OrgDetailsDTO `json:"body"` +} diff --git a/pkg/api/org_invite.go b/pkg/api/org_invite.go index c543150530c..5044d0a4ba6 100644 --- a/pkg/api/org_invite.go +++ b/pkg/api/org_invite.go @@ -19,6 +19,15 @@ import ( "github.com/grafana/grafana/pkg/web" ) +// swagger:route GET /org/invites org_invites getPendingOrgInvites +// +// Get pending invites. +// +// Responses: +// 200: getPendingOrgInvitesResponse +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) GetPendingOrgInvites(c *models.ReqContext) response.Response { query := models.GetTempUsersQuery{OrgId: c.OrgId, Status: models.TmpUserInvitePending} @@ -33,6 +42,17 @@ func (hs *HTTPServer) GetPendingOrgInvites(c *models.ReqContext) response.Respon return response.JSON(http.StatusOK, query.Result) } +// swagger:route POST /org/invites org_invites addOrgInvite +// +// Add invite. +// +// Responses: +// 200: okResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 412: SMTPNotEnabledError +// 500: internalServerError func (hs *HTTPServer) AddOrgInvite(c *models.ReqContext) response.Response { inviteDto := dtos.AddInviteForm{} if err := web.Bind(c.Req, &inviteDto); err != nil { @@ -159,6 +179,16 @@ func (hs *HTTPServer) inviteExistingUserToOrg(c *models.ReqContext, user *user.U }) } +// swagger:route DELETE /org/invites/{invitation_code}/revoke org_invites revokeInvite +// +// Revoke invite. +// +// Responses: +// 200: okResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) RevokeInvite(c *models.ReqContext) response.Response { if ok, rsp := hs.updateTempUserStatus(c.Req.Context(), web.Params(c.Req)[":code"], models.TmpUserRevoked); !ok { return rsp @@ -286,3 +316,24 @@ func (hs *HTTPServer) applyUserInvite(ctx context.Context, user *user.User, invi return true, nil } + +// swagger:parameters addOrgInvite +type AddInviteParams struct { + // in:body + // required:true + Body dtos.AddInviteForm `json:"body"` +} + +// swagger:parameters revokeInvite +type RevokeInviteParams struct { + // in:path + // required:true + Code string `json:"invitation_code"` +} + +// swagger:response getPendingOrgInvitesResponse +type GetPendingOrgInvitesResponse struct { + // The response message + // in: body + Body []*models.TempUserDTO `json:"body"` +} diff --git a/pkg/api/org_users.go b/pkg/api/org_users.go index 47ecd1156bc..8905aa9fcd6 100644 --- a/pkg/api/org_users.go +++ b/pkg/api/org_users.go @@ -14,7 +14,20 @@ import ( "github.com/grafana/grafana/pkg/web" ) -// POST /api/org/users +// swagger:route POST /org/users org addOrgUserToCurrentOrg +// +// Add a new user to the current organization +// +// Adds a global user to the current organization. +// +// If you are running Grafana Enterprise and have Fine-grained access control enabled +// you need to have a permission with action: `org.users:add` with scope `users:*`. +// +// Responses: +// 200: okResponse +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) AddOrgUserToCurrentOrg(c *models.ReqContext) response.Response { cmd := models.AddOrgUserCommand{} if err := web.Bind(c.Req, &cmd); err != nil { @@ -24,7 +37,20 @@ func (hs *HTTPServer) AddOrgUserToCurrentOrg(c *models.ReqContext) response.Resp return hs.addOrgUserHelper(c, cmd) } -// POST /api/orgs/:orgId/users +// swagger:route POST /orgs/{org_id}/users orgs addOrgUser +// +// Add a new user to the current organization +// +// Adds a global user to the current organization. +// +// If you are running Grafana Enterprise and have Fine-grained access control enabled +// you need to have a permission with action: `org.users:add` with scope `users:*`. +// +// Responses: +// 200: okResponse +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) AddOrgUser(c *models.ReqContext) response.Response { cmd := models.AddOrgUserCommand{} if err := web.Bind(c.Req, &cmd); err != nil { @@ -73,7 +99,19 @@ func (hs *HTTPServer) addOrgUserHelper(c *models.ReqContext, cmd models.AddOrgUs }) } -// GET /api/org/users +// swagger:route GET /org/users org getOrgUsersForCurrentOrg +// +// Get all users within the current organization. +// +// Returns all org users within the current organization. Accessible to users with org admin role. +// If you are running Grafana Enterprise and have Fine-grained access control enabled +// you need to have a permission with action: `org.users:read` with scope `users:*`. +// +// Responses: +// 200: getOrgUsersForCurrentOrgResponse +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) GetOrgUsersForCurrentOrg(c *models.ReqContext) response.Response { result, err := hs.getOrgUsersHelper(c, &models.GetOrgUsersQuery{ OrgId: c.OrgId, @@ -89,7 +127,20 @@ func (hs *HTTPServer) GetOrgUsersForCurrentOrg(c *models.ReqContext) response.Re return response.JSON(http.StatusOK, result) } -// GET /api/org/users/lookup +// swagger:route GET /org/users/lookup org getOrgUsersForCurrentOrgLookup +// +// Get all users within the current organization (lookup) +// +// Returns all org users within the current organization, but with less detailed information. +// Accessible to users with org admin role, admin in any folder or admin of any team. +// Mainly used by Grafana UI for providing list of users when adding team members and when editing folder/dashboard permissions. +// +// Responses: +// 200: getOrgUsersForCurrentOrgLookupResponse +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError + func (hs *HTTPServer) GetOrgUsersForCurrentOrgLookup(c *models.ReqContext) response.Response { orgUsers, err := hs.getOrgUsersHelper(c, &models.GetOrgUsersQuery{ OrgId: c.OrgId, @@ -116,7 +167,21 @@ func (hs *HTTPServer) GetOrgUsersForCurrentOrgLookup(c *models.ReqContext) respo return response.JSON(http.StatusOK, result) } -// GET /api/orgs/:orgId/users +// swagger:route GET /orgs/{org_id}/users orgs getOrgUsers +// +// Get Users in Organization. +// +// If you are running Grafana Enterprise and have Fine-grained access control enabled +// you need to have a permission with action: `org.users:read` with scope `users:*`. +// +// Security: +// - basic: +// +// Responses: +// 200: getOrgUsersResponse +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) GetOrgUsers(c *models.ReqContext) response.Response { orgId, err := strconv.ParseInt(web.Params(c.Req)[":orgId"], 10, 64) if err != nil { @@ -208,7 +273,19 @@ func (hs *HTTPServer) SearchOrgUsersWithPaging(c *models.ReqContext) response.Re return response.JSON(http.StatusOK, query.Result) } -// PATCH /api/org/users/:userId +// swagger:route PATCH /org/users/{user_id} org updateOrgUserForCurrentOrg +// +// Updates the given user +// +// If you are running Grafana Enterprise and have Fine-grained access control enabled +// you need to have a permission with action: `org.users.role:update` with scope `users:*`. +// +// Responses: +// 200: okResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) UpdateOrgUserForCurrentOrg(c *models.ReqContext) response.Response { cmd := models.UpdateOrgUserCommand{} if err := web.Bind(c.Req, &cmd); err != nil { @@ -223,7 +300,19 @@ func (hs *HTTPServer) UpdateOrgUserForCurrentOrg(c *models.ReqContext) response. return hs.updateOrgUserHelper(c, cmd) } -// PATCH /api/orgs/:orgId/users/:userId +// swagger:route PATCH /orgs/{org_id}/users/{user_id} orgs updateOrgUser +// +// Update Users in Organization. +// +// If you are running Grafana Enterprise and have Fine-grained access control enabled +// you need to have a permission with action: `org.users.role:update` with scope `users:*`. +// +// Responses: +// 200: okResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) UpdateOrgUser(c *models.ReqContext) response.Response { cmd := models.UpdateOrgUserCommand{} var err error @@ -258,7 +347,19 @@ func (hs *HTTPServer) updateOrgUserHelper(c *models.ReqContext, cmd models.Updat return response.Success("Organization user updated") } -// DELETE /api/org/users/:userId +// swagger:route DELETE /org/users/{user_id} org removeOrgUserForCurrentOrg +// +// Delete user in current organization +// +// If you are running Grafana Enterprise and have Fine-grained access control enabled +// you need to have a permission with action: `org.users:remove` with scope `users:*`. +// +// Responses: +// 200: okResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) RemoveOrgUserForCurrentOrg(c *models.ReqContext) response.Response { userId, err := strconv.ParseInt(web.Params(c.Req)[":userId"], 10, 64) if err != nil { @@ -272,7 +373,19 @@ func (hs *HTTPServer) RemoveOrgUserForCurrentOrg(c *models.ReqContext) response. }) } -// DELETE /api/orgs/:orgId/users/:userId +// swagger:route DELETE /orgs/{org_id}/users/{user_id} orgs removeOrgUser +// +// Delete user in current organization +// +// If you are running Grafana Enterprise and have Fine-grained access control enabled +// you need to have a permission with action: `org.users:remove` with scope `users:*`. +// +// Responses: +// 200: okResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) RemoveOrgUser(c *models.ReqContext) response.Response { userId, err := strconv.ParseInt(web.Params(c.Req)[":userId"], 10, 64) if err != nil { @@ -302,3 +415,98 @@ func (hs *HTTPServer) removeOrgUserHelper(ctx context.Context, cmd *models.Remov return response.Success("User removed from organization") } + +// swagger:parameters addOrgUserToCurrentOrg +type AddOrgUserToCurrentOrgParams struct { + // in:body + // required:true + Body models.AddOrgUserCommand `json:"body"` +} + +// swagger:parameters addOrgUser +type AddOrgUserParams struct { + // in:body + // required:true + Body models.AddOrgUserCommand `json:"body"` + // in:path + // required:true + OrgID int64 `json:"org_id"` +} + +// swagger:parameters getOrgUsersForCurrentOrgLookup +type LookupOrgUsersParams struct { + // in:query + // required:false + Query string `json:"query"` + // in:query + // required:false + Limit int `json:"limit"` +} + +// swagger:parameters getOrgUsers +type GetOrgUsersParams struct { + // in:path + // required:true + OrgID int64 `json:"org_id"` +} + +// swagger:parameters updateOrgUserForCurrentOrg +type UpdateOrgUserForCurrentOrgParams struct { + // in:body + // required:true + Body models.UpdateOrgUserCommand `json:"body"` + // in:path + // required:true + UserID int64 `json:"user_id"` +} + +// swagger:parameters updateOrgUser +type UpdateOrgUserParams struct { + // in:body + // required:true + Body models.UpdateOrgUserCommand `json:"body"` + // in:path + // required:true + OrgID int64 `json:"org_id"` + // in:path + // required:true + UserID int64 `json:"user_id"` +} + +// swagger:parameters removeOrgUserForCurrentOrg +type RemoveOrgUserForCurrentOrgParams struct { + // in:path + // required:true + UserID int64 `json:"user_id"` +} + +// swagger:parameters removeOrgUser +type RemoveOrgUserParams struct { + // in:path + // required:true + OrgID int64 `json:"org_id"` + // in:path + // required:true + UserID int64 `json:"user_id"` +} + +// swagger:response getOrgUsersForCurrentOrgLookupResponse +type GetOrgUsersForCurrentOrgLookupResponse struct { + // The response message + // in: body + Body []*dtos.UserLookupDTO `json:"body"` +} + +// swagger:response getOrgUsersForCurrentOrgResponse +type GetOrgUsersForCurrentOrgResponse struct { + // The response message + // in: body + Body []*models.OrgUserDTO `json:"body"` +} + +// swagger:response getOrgUsersResponse +type GetOrgUsersResponse struct { + // The response message + // in: body + Body []*models.OrgUserDTO `json:"body"` +} diff --git a/pkg/api/playlist.go b/pkg/api/playlist.go index 6c85aec19d8..f58a9805cc0 100644 --- a/pkg/api/playlist.go +++ b/pkg/api/playlist.go @@ -4,6 +4,7 @@ import ( "context" "net/http" + "github.com/grafana/grafana/pkg/api/dtos" "github.com/grafana/grafana/pkg/api/response" "github.com/grafana/grafana/pkg/models" "github.com/grafana/grafana/pkg/services/playlist" @@ -31,6 +32,13 @@ func (hs *HTTPServer) ValidateOrgPlaylist(c *models.ReqContext) { } } +// swagger:route GET /playlists playlists searchPlaylists +// +// Get playlists. +// +// Responses: +// 200: searchPlaylistsResponse +// 500: internalServerError func (hs *HTTPServer) SearchPlaylists(c *models.ReqContext) response.Response { query := c.Query("query") limit := c.QueryInt("limit") @@ -53,6 +61,16 @@ func (hs *HTTPServer) SearchPlaylists(c *models.ReqContext) response.Response { return response.JSON(http.StatusOK, playlists) } +// swagger:route GET /playlists/{uid} playlists getPlaylist +// +// Get playlist. +// +// Responses: +// 200: getPlaylistResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) GetPlaylist(c *models.ReqContext) response.Response { uid := web.Params(c.Req)[":uid"] cmd := playlist.GetPlaylistByUidQuery{UID: uid, OrgId: c.OrgId} @@ -109,6 +127,16 @@ func (hs *HTTPServer) LoadPlaylistItems(ctx context.Context, uid string, orgId i return items, nil } +// swagger:route GET /playlists/{uid}/items playlists getPlaylistItems +// +// Get playlist items. +// +// Responses: +// 200: getPlaylistItemsResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) GetPlaylistItems(c *models.ReqContext) response.Response { uid := web.Params(c.Req)[":uid"] @@ -121,6 +149,16 @@ func (hs *HTTPServer) GetPlaylistItems(c *models.ReqContext) response.Response { return response.JSON(http.StatusOK, playlistDTOs) } +// swagger:route GET /playlists/{uid}/dashboards playlists getPlaylistDashboards +// +// Get playlist dashboards. +// +// Responses: +// 200: getPlaylistDashboardsResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) GetPlaylistDashboards(c *models.ReqContext) response.Response { playlistUID := web.Params(c.Req)[":uid"] @@ -132,6 +170,16 @@ func (hs *HTTPServer) GetPlaylistDashboards(c *models.ReqContext) response.Respo return response.JSON(http.StatusOK, playlists) } +// swagger:route DELETE /playlists/{uid} playlists deletePlaylist +// +// Delete playlist. +// +// Responses: +// 200: okResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) DeletePlaylist(c *models.ReqContext) response.Response { uid := web.Params(c.Req)[":uid"] @@ -143,6 +191,16 @@ func (hs *HTTPServer) DeletePlaylist(c *models.ReqContext) response.Response { return response.JSON(http.StatusOK, "") } +// swagger:route POST /playlists playlists createPlaylist +// +// Create playlist. +// +// Responses: +// 200: createPlaylistResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) CreatePlaylist(c *models.ReqContext) response.Response { cmd := playlist.CreatePlaylistCommand{} if err := web.Bind(c.Req, &cmd); err != nil { @@ -158,6 +216,16 @@ func (hs *HTTPServer) CreatePlaylist(c *models.ReqContext) response.Response { return response.JSON(http.StatusOK, p) } +// swagger:route PUT /playlists/{uid} playlists updatePlaylist +// +// Update playlist. +// +// Responses: +// 200: updatePlaylistResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) UpdatePlaylist(c *models.ReqContext) response.Response { cmd := playlist.UpdatePlaylistCommand{} if err := web.Bind(c.Req, &cmd); err != nil { @@ -179,3 +247,100 @@ func (hs *HTTPServer) UpdatePlaylist(c *models.ReqContext) response.Response { p.Items = playlistDTOs return response.JSON(http.StatusOK, p) } + +// swagger:parameters searchPlaylists +type SearchPlaylistsParams struct { + // in:query + // required:false + Query string `json:"query"` + // in:limit + // required:false + Limit int `json:"limit"` +} + +// swagger:parameters getPlaylist +type GetPlaylistParams struct { + // in:path + // required:true + UID string `json:"uid"` +} + +// swagger:parameters getPlaylistItems +type GetPlaylistItemsParams struct { + // in:path + // required:true + UID string `json:"uid"` +} + +// swagger:parameters getPlaylistDashboards +type GetPlaylistDashboardsParams struct { + // in:path + // required:true + UID string `json:"uid"` +} + +// swagger:parameters deletePlaylist +type DeletePlaylistParams struct { + // in:path + // required:true + UID string `json:"uid"` +} + +// swagger:parameters updatePlaylist +type UpdatePlaylistParams struct { + // in:body + // required:true + Body playlist.UpdatePlaylistCommand + // in:path + // required:true + UID string `json:"uid"` +} + +// swagger:parameters createPlaylist +type CreatePlaylistParams struct { + // in:body + // required:true + Body playlist.CreatePlaylistCommand +} + +// swagger:response searchPlaylistsResponse +type SearchPlaylistsResponse struct { + // The response message + // in: body + Body playlist.Playlists `json:"body"` +} + +// swagger:response getPlaylistResponse +type GetPlaylistResponse struct { + // The response message + // in: body + Body *playlist.PlaylistDTO `json:"body"` +} + +// swagger:response getPlaylistItemsResponse +type GetPlaylistItemsResponse struct { + // The response message + // in: body + Body []playlist.PlaylistItemDTO `json:"body"` +} + +// swagger:response getPlaylistDashboardsResponse +type GetPlaylistDashboardsResponse struct { + // The response message + // in: body + Body dtos.PlaylistDashboardsSlice `json:"body"` +} + +// swagger:response updatePlaylistResponse +type UpdatePlaylistResponse struct { + // The response message + // in: body + Body *playlist.PlaylistDTO `json:"body"` +} + +// swagger:response createPlaylistResponse +type CreatePlaylistResponse struct { + // The response message + // in: body + Body *playlist.Playlist `json:"body"` +} diff --git a/pkg/api/preferences.go b/pkg/api/preferences.go index e13f6b07837..d6322a53262 100644 --- a/pkg/api/preferences.go +++ b/pkg/api/preferences.go @@ -47,7 +47,14 @@ func (hs *HTTPServer) SetHomeDashboard(c *models.ReqContext) response.Response { return response.Success("Home dashboard set") } -// GET /api/user/preferences +// swagger:route GET /user/preferences user_preferences getUserPreferences +// +// Get user preferences. +// +// Responses: +// 200: getPreferencesResponse +// 401: unauthorisedError +// 500: internalServerError func (hs *HTTPServer) GetUserPreferences(c *models.ReqContext) response.Response { return hs.getPreferencesFor(c.Req.Context(), c.OrgId, c.UserId, 0) } @@ -88,7 +95,17 @@ func (hs *HTTPServer) getPreferencesFor(ctx context.Context, orgID, userID, team return response.JSON(http.StatusOK, &dto) } -// PUT /api/user/preferences +// swagger:route PUT /user/preferences user_preferences updateUserPreferences +// +// Update user preferences. +// +// Omitting a key (`theme`, `homeDashboardId`, `timezone`) will cause the current value to be replaced with the system default value. +// +// Responses: +// 200: okResponse +// 400: badRequestError +// 401: unauthorisedError +// 500: internalServerError func (hs *HTTPServer) UpdateUserPreferences(c *models.ReqContext) response.Response { dtoCmd := dtos.UpdatePrefsCmd{} if err := web.Bind(c.Req, &dtoCmd); err != nil { @@ -133,7 +150,15 @@ func (hs *HTTPServer) updatePreferencesFor(ctx context.Context, orgID, userID, t return response.Success("Preferences updated") } -// PATCH /api/user/preferences +// swagger:route PATCH /user/preferences user_preferences patchUserPreferences +// +// Patch user preferences. +// +// Responses: +// 200: okResponse +// 400: badRequestError +// 401: unauthorisedError +// 500: internalServerError func (hs *HTTPServer) PatchUserPreferences(c *models.ReqContext) response.Response { dtoCmd := dtos.PatchPrefsCmd{} if err := web.Bind(c.Req, &dtoCmd); err != nil { @@ -179,12 +204,29 @@ func (hs *HTTPServer) patchPreferencesFor(ctx context.Context, orgID, userID, te return response.Success("Preferences updated") } -// GET /api/org/preferences +// swagger:route GET /org/preferences org_preferences getOrgPreferences +// +// Get Current Org Prefs. +// +// Responses: +// 200: getPreferencesResponse +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) GetOrgPreferences(c *models.ReqContext) response.Response { return hs.getPreferencesFor(c.Req.Context(), c.OrgId, 0, 0) } -// PUT /api/org/preferences +// swagger:route PUT /org/preferences org_preferences updateOrgPreferences +// +// Update Current Org Prefs. +// +// Responses: +// 200: okResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) UpdateOrgPreferences(c *models.ReqContext) response.Response { dtoCmd := dtos.UpdatePrefsCmd{} if err := web.Bind(c.Req, &dtoCmd); err != nil { @@ -194,7 +236,16 @@ func (hs *HTTPServer) UpdateOrgPreferences(c *models.ReqContext) response.Respon return hs.updatePreferencesFor(c.Req.Context(), c.OrgId, 0, 0, &dtoCmd) } -// PATCH /api/org/preferences +// swagger:route PATCH /org/preferences org_preferences patchOrgPreferences +// +// Patch Current Org Prefs. +// +// Responses: +// 200: okResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) PatchOrgPreferences(c *models.ReqContext) response.Response { dtoCmd := dtos.PatchPrefsCmd{} if err := web.Bind(c.Req, &dtoCmd); err != nil { @@ -202,3 +253,37 @@ func (hs *HTTPServer) PatchOrgPreferences(c *models.ReqContext) response.Respons } return hs.patchPreferencesFor(c.Req.Context(), c.OrgId, 0, 0, &dtoCmd) } + +// swagger:parameters updateUserPreferences +type UpdateUserPreferencesParams struct { + // in:body + // required:true + Body dtos.UpdatePrefsCmd `json:"body"` +} + +// swagger:parameters updateOrgPreferences +type UpdateOrgPreferencesParams struct { + // in:body + // required:true + Body dtos.UpdatePrefsCmd `json:"body"` +} + +// swagger:response getPreferencesResponse +type GetPreferencesResponse struct { + // in:body + Body dtos.Prefs `json:"body"` +} + +// swagger:parameters patchUserPreferences +type PatchUserPreferencesParams struct { + // in:body + // required:true + Body dtos.PatchPrefsCmd `json:"body"` +} + +// swagger:parameters patchOrgPreferences +type PatchOrgPreferencesParams struct { + // in:body + // required:true + Body dtos.PatchPrefsCmd `json:"body"` +} diff --git a/pkg/api/quota.go b/pkg/api/quota.go index 79d304dbf9e..32a9fda92c5 100644 --- a/pkg/api/quota.go +++ b/pkg/api/quota.go @@ -14,6 +14,18 @@ func (hs *HTTPServer) GetCurrentOrgQuotas(c *models.ReqContext) response.Respons return hs.getOrgQuotasHelper(c, c.OrgId) } +// swagger:route GET /orgs/{org_id}/quotas orgs getOrgQuota +// +// Fetch Organization quota. +// +// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `orgs.quotas:read` and scope `org:id:1` (orgIDScope). +//list +// Responses: +// 200: getQuotaResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) GetOrgQuotas(c *models.ReqContext) response.Response { orgId, err := strconv.ParseInt(web.Params(c.Req)[":orgId"], 10, 64) if err != nil { @@ -35,6 +47,21 @@ func (hs *HTTPServer) getOrgQuotasHelper(c *models.ReqContext, orgID int64) resp return response.JSON(http.StatusOK, query.Result) } +// swagger:route PUT /orgs/{org_id}/quotas/{quota_target} orgs updateOrgQuota +// +// Update user quota. +// +// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `orgs.quotas:write` and scope `org:id:1` (orgIDScope). +// +// Security: +// - basic: +// +// Responses: +// 200: okResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) UpdateOrgQuota(c *models.ReqContext) response.Response { cmd := models.UpdateOrgQuotaCmd{} var err error @@ -60,6 +87,32 @@ func (hs *HTTPServer) UpdateOrgQuota(c *models.ReqContext) response.Response { return response.Success("Organization quota updated") } +// swagger:route GET /admin/users/{user_id}/quotas admin_users getUserQuota +// +// Fetch user quota. +// +// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `users.quotas:list` and scope `global.users:1` (userIDScope). +// +// Security: +// - basic: +// +// Responses: +// 200: getQuotaResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError + +// swagger:route GET /user/quotas signed_in_user getUserQuotas +// +// Fetch user quota. +// +// Responses: +// 200: getQuotaResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) GetUserQuotas(c *models.ReqContext) response.Response { if !setting.Quota.Enabled { return response.Error(404, "Quotas not enabled", nil) @@ -79,6 +132,21 @@ func (hs *HTTPServer) GetUserQuotas(c *models.ReqContext) response.Response { return response.JSON(http.StatusOK, query.Result) } +// swagger:route PUT /admin/users/{user_id}/quotas/{quota_target} admin_users updateUserQuota +// +// Update user quota. +// +// If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `users.quotas:update` and scope `global.users:1` (userIDScope). +// +// Security: +// - basic: +// +// Responses: +// 200: okResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) UpdateUserQuota(c *models.ReqContext) response.Response { cmd := models.UpdateUserQuotaCmd{} var err error @@ -103,3 +171,49 @@ func (hs *HTTPServer) UpdateUserQuota(c *models.ReqContext) response.Response { } return response.Success("Organization quota updated") } + +// swagger:parameters updateUserQuota +type UpdateUserQuotaParams struct { + // in:body + // required:true + Body models.UpdateUserQuotaCmd `json:"body"` + // in:path + // required:true + QuotaTarget string `json:"quota_target"` + // in:path + // required:true + UserID int64 `json:"user_id"` +} + +// swagger:parameters getUserQuota +type GetUserQuotaParams struct { + // in:path + // required:true + UserID int64 `json:"user_id"` +} + +// swagger:parameters getOrgQuota +type GetOrgQuotaParams struct { + // in:path + // required:true + OrgID int64 `json:"org_id"` +} + +// swagger:parameters updateOrgQuota +type UpdateOrgQuotaParam struct { + // in:body + // required:true + Body models.UpdateOrgQuotaCmd `json:"body"` + // in:path + // required:true + QuotaTarget string `json:"quota_target"` + // in:path + // required:true + OrgID int64 `json:"org_id"` +} + +// swagger:response getQuotaResponse +type GetQuotaResponseResponse struct { + // in:body + Body []*models.UserQuotaDTO `json:"body"` +} diff --git a/pkg/api/search.go b/pkg/api/search.go index bbb9fa58d8a..b2cc4b431e4 100644 --- a/pkg/api/search.go +++ b/pkg/api/search.go @@ -13,6 +13,13 @@ import ( "github.com/grafana/grafana/pkg/util" ) +// swagger:route GET /search search search +// +// Responses: +// 200: searchResponse +// 401: unauthorisedError +// 422: unprocessableEntityError +// 500: internalServerError func (hs *HTTPServer) Search(c *models.ReqContext) response.Response { query := c.Query("query") tags := c.QueryStrings("tag") @@ -122,6 +129,13 @@ func (hs *HTTPServer) searchHitsWithMetadata(c *models.ReqContext, hits models.H return response.JSON(http.StatusOK, hitsWithMeta) } +// swagger:route GET /search/sorting search listSortOptions +// +// List search sorting options +// +// Responses: +// 200: listSortOptionsResponse +// 401: unauthorisedError func (hs *HTTPServer) ListSortOptions(c *models.ReqContext) response.Response { opts := hs.SearchService.SortOptions() @@ -139,3 +153,78 @@ func (hs *HTTPServer) ListSortOptions(c *models.ReqContext) response.Response { "sortOptions": res, }) } + +// swagger:parameters search +type SearchParams struct { + // Search Query + // in:query + // required: false + Query string `json:"query"` + // List of tags to search for + // in:query + // required: false + // type: array + // collectionFormat: multi + Tag []string `json:"tag"` + // Type to search for, dash-folder or dash-db + // in:query + // required: false + // Description: + // * `dash-folder` - Search for folder + // * `dash-db` - Seatch for dashboard + // Enum: dash-folder,dash-db + Type string `json:"type"` + // List of dashboard id’s to search for + // in:query + // required: false + DashboardIds []int64 `json:"dashboardIds"` + // List of dashboard uid’s to search for + // in:query + // required: false + DashboardUIDs []string `json:"dashboardUIDs"` + // List of folder id’s to search in for dashboards + // in:query + // required: false + FolderIds []int64 `json:"folderIds"` + // Flag indicating if only starred Dashboards should be returned + // in:query + // required: false + Starred bool `json:"starred"` + // Limit the number of returned results (max 5000) + // in:query + // required: false + Limit int64 `json:"limit"` + // Use this parameter to access hits beyond limit. Numbering starts at 1. limit param acts as page size. Only available in Grafana v6.2+. + // in:query + // required: false + Page int64 `json:"page"` + // Set to `Edit` to return dashboards/folders that the user can edit + // in:query + // required: false + // default:View + // Enum: Edit,View + Permission string `json:"permission"` + // Sort method; for listing all the possible sort methods use the search sorting endpoint. + // in:query + // required: false + // default: alpha-asc + // Enum: alpha-asc,alpha-desc + Sort string `json:"sort"` +} + +// swagger:response searchResponse +type SearchResponse struct { + // in: body + Body models.HitList `json:"body"` +} + +// swagger:response listSortOptionsResponse +type ListSortOptionsResponse struct { + // in: body + Body struct { + Name string `json:"name"` + DisplayName string `json:"displayName"` + Description string `json:"description"` + Meta string `json:"meta"` + } `json:"body"` +} diff --git a/pkg/api/stars.go b/pkg/api/stars.go index fb8e76114ac..78e2409a0a3 100644 --- a/pkg/api/stars.go +++ b/pkg/api/stars.go @@ -36,6 +36,18 @@ func (hs *HTTPServer) GetStars(c *models.ReqContext) response.Response { return response.JSON(200, uids) } +// swagger:route POST /user/stars/dashboard/{dashboard_id} signed_in_user starDashboard +// +// Star a dashboard. +// +// Stars the given Dashboard for the actual user. +// +// Responses: +// 200: okResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) StarDashboard(c *models.ReqContext) response.Response { id, err := strconv.ParseInt(web.Params(c.Req)[":id"], 10, 64) if err != nil { @@ -54,6 +66,18 @@ func (hs *HTTPServer) StarDashboard(c *models.ReqContext) response.Response { return response.Success("Dashboard starred!") } +// swagger:route DELETE /user/stars/dashboard/{dashboard_id} signed_in_user unstarDashboard +// +// Unstar a dashboard. +// +// Deletes the starring of the given Dashboard for the actual user. +// +// Responses: +// 200: okResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) UnstarDashboard(c *models.ReqContext) response.Response { id, err := strconv.ParseInt(web.Params(c.Req)[":id"], 10, 64) if err != nil { @@ -71,3 +95,17 @@ func (hs *HTTPServer) UnstarDashboard(c *models.ReqContext) response.Response { return response.Success("Dashboard unstarred") } + +// swagger:parameters starDashboard +type StarDashboardParams struct { + // in:path + // required:true + DashboardID string `json:"dashboard_id"` +} + +// swagger:parameters unstarDashboard +type UnstarDashboardParams struct { + // in:path + // required:true + DashboardID string `json:"dashboard_id"` +} diff --git a/pkg/api/docs/definitions/responses.go b/pkg/api/swagger_responses.go similarity index 99% rename from pkg/api/docs/definitions/responses.go rename to pkg/api/swagger_responses.go index 712360880b8..49e310051d8 100644 --- a/pkg/api/docs/definitions/responses.go +++ b/pkg/api/swagger_responses.go @@ -1,4 +1,4 @@ -package definitions +package api // A GenericError is the default error message that is generated. // For certain status codes there are more appropriate error structures. diff --git a/pkg/api/docs/tags.json b/pkg/api/swagger_tags.json similarity index 99% rename from pkg/api/docs/tags.json rename to pkg/api/swagger_tags.json index 38a36cb79bc..43228f641f4 100644 --- a/pkg/api/docs/tags.json +++ b/pkg/api/swagger_tags.json @@ -41,7 +41,7 @@ "description": "The Admin Organizations HTTP API does not currently work with an API Token. API Tokens are currently only linked to an organization and an organization role. They cannot be given the permission of server admin, only users can be given that permission. So in order to use these API calls you will have to use Basic Auth and the Grafana user must have the Grafana Admin permission (The default admin user is called `admin` and has permission to use this API)." }, { - "name": "current_org_details", + "name": "org", "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled, for some endpoints you would need to have relevant permissions. Refer to specific resources to understand what permissions are required." }, { diff --git a/pkg/api/team.go b/pkg/api/team.go index cfd44400e06..baf057f3fd2 100644 --- a/pkg/api/team.go +++ b/pkg/api/team.go @@ -12,7 +12,16 @@ import ( "github.com/grafana/grafana/pkg/web" ) -// POST /api/teams +// swagger:route POST /teams teams createTeam +// +// Add Team. +// +// Responses: +// 200: createTeamResponse +// 401: unauthorisedError +// 403: forbiddenError +// 409: conflictError +// 500: internalServerError func (hs *HTTPServer) CreateTeam(c *models.ReqContext) response.Response { cmd := models.CreateTeamCommand{} if err := web.Bind(c.Req, &cmd); err != nil { @@ -49,7 +58,17 @@ func (hs *HTTPServer) CreateTeam(c *models.ReqContext) response.Response { }) } -// PUT /api/teams/:teamId +// swagger:route PUT /teams/{team_id} teams updateTeam +// +// Update Team. +// +// Responses: +// 200: okResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 409: conflictError +// 500: internalServerError func (hs *HTTPServer) UpdateTeam(c *models.ReqContext) response.Response { cmd := models.UpdateTeamCommand{} var err error @@ -78,7 +97,16 @@ func (hs *HTTPServer) UpdateTeam(c *models.ReqContext) response.Response { return response.Success("Team updated") } -// DELETE /api/teams/:teamId +// swagger:route DELETE /teams/{team_id} teams deleteTeamByID +// +// Delete Team By ID. +// +// Responses: +// 200: okResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) DeleteTeamByID(c *models.ReqContext) response.Response { orgId := c.OrgId teamId, err := strconv.ParseInt(web.Params(c.Req)[":teamId"], 10, 64) @@ -102,7 +130,15 @@ func (hs *HTTPServer) DeleteTeamByID(c *models.ReqContext) response.Response { return response.Success("Team deleted") } -// GET /api/teams/search +// swagger:route GET /teams/search teams searchTeams +// +// Team Search With Paging. +// +// Responses: +// 200: searchTeamsResponse +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) SearchTeams(c *models.ReqContext) response.Response { perPage := c.QueryInt("perpage") if perPage <= 0 { @@ -164,7 +200,16 @@ func userFilter(c *models.ReqContext) int64 { return userIdFilter } -// GET /api/teams/:teamId +// swagger:route GET /teams/{team_id} teams getTeamByID +// +// Get Team By ID. +// +// Responses: +// 200: getTeamByIDResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) GetTeamByID(c *models.ReqContext) response.Response { teamId, err := strconv.ParseInt(web.Params(c.Req)[":teamId"], 10, 64) if err != nil { @@ -200,7 +245,14 @@ func (hs *HTTPServer) GetTeamByID(c *models.ReqContext) response.Response { return response.JSON(http.StatusOK, &query.Result) } -// GET /api/teams/:teamId/preferences +// swagger:route GET /teams/{team_id}/preferences teams getTeamPreferences +// +// Get Team Preferences. +// +// Responses: +// 200: getPreferencesResponse +// 401: unauthorisedError +// 500: internalServerError func (hs *HTTPServer) GetTeamPreferences(c *models.ReqContext) response.Response { teamId, err := strconv.ParseInt(web.Params(c.Req)[":teamId"], 10, 64) if err != nil { @@ -218,7 +270,15 @@ func (hs *HTTPServer) GetTeamPreferences(c *models.ReqContext) response.Response return hs.getPreferencesFor(c.Req.Context(), orgId, 0, teamId) } -// PUT /api/teams/:teamId/preferences +// swagger:route PUT /teams/{team_id}/preferences teams updateTeamPreferences +// +// Update Team Preferences. +// +// Responses: +// 200: okResponse +// 400: badRequestError +// 401: unauthorisedError +// 500: internalServerError func (hs *HTTPServer) UpdateTeamPreferences(c *models.ReqContext) response.Response { dtoCmd := dtos.UpdatePrefsCmd{} if err := web.Bind(c.Req, &dtoCmd); err != nil { @@ -240,3 +300,93 @@ func (hs *HTTPServer) UpdateTeamPreferences(c *models.ReqContext) response.Respo return hs.updatePreferencesFor(c.Req.Context(), orgId, 0, teamId, &dtoCmd) } + +// swagger:parameters updateTeamPreferences +type UpdateTeamPreferencesParams struct { + // in:path + // required:true + TeamID string `json:"team_id"` + // in:body + // required:true + Body dtos.UpdatePrefsCmd `json:"body"` +} + +// swagger:parameters getTeamByID +type GetTeamByIDParams struct { + // in:path + // required:true + TeamID string `json:"team_id"` +} + +// swagger:parameters deleteTeamByID +type DeleteTeamByIDParams struct { + // in:path + // required:true + TeamID string `json:"team_id"` +} + +// swagger:parameters getTeamPreferences +type GetTeamPreferencesParams struct { + // in:path + // required:true + TeamID string `json:"team_id"` +} + +// swagger:parameters searchTeams +type SearchTeamsParams struct { + // in:query + // required:false + // default: 1 + Page int `json:"page"` + // Number of items per page + // The totalCount field in the response can be used for pagination list E.g. if totalCount is equal to 100 teams and the perpage parameter is set to 10 then there are 10 pages of teams. + // in:query + // required:false + // default: 1000 + PerPage int `json:"perpage"` + Name string `json:"name"` + // If set it will return results where the query value is contained in the name field. Query values with spaces need to be URL encoded. + // required:false + Query string `json:"query"` +} + +// swagger:parameters createTeam +type CreateTeamParams struct { + // in:body + // required:true + Body models.CreateTeamCommand `json:"body"` +} + +// swagger:parameters updateTeam +type UpdateTeamParams struct { + // in:body + // required:true + Body models.UpdateTeamCommand `json:"body"` + // in:path + // required:true + TeamID string `json:"team_id"` +} + +// swagger:response searchTeamsResponse +type SearchTeamsResponse struct { + // The response message + // in: body + Body models.SearchTeamQueryResult `json:"body"` +} + +// swagger:response getTeamByIDResponse +type GetTeamByIDResponse struct { + // The response message + // in: body + Body *models.TeamDTO `json:"body"` +} + +// swagger:response createTeamResponse +type CreateTeamResponse struct { + // The response message + // in: body + Body struct { + TeamId int64 `json:"teamId"` + Message string `json:"message"` + } `json:"body"` +} diff --git a/pkg/api/team_members.go b/pkg/api/team_members.go index 834b40a33bc..a8fa84d7011 100644 --- a/pkg/api/team_members.go +++ b/pkg/api/team_members.go @@ -15,7 +15,16 @@ import ( "github.com/grafana/grafana/pkg/web" ) -// GET /api/teams/:teamId/members +// swagger:route GET /teams/{team_id}/members teams getTeamMembers +// +// Get Team Members. +// +// Responses: +// 200: getTeamMembersResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) GetTeamMembers(c *models.ReqContext) response.Response { teamId, err := strconv.ParseInt(web.Params(c.Req)[":teamId"], 10, 64) if err != nil { @@ -56,7 +65,16 @@ func (hs *HTTPServer) GetTeamMembers(c *models.ReqContext) response.Response { return response.JSON(http.StatusOK, filteredMembers) } -// POST /api/teams/:teamId/members +// swagger:route POST /teams/{team_id}/members teams addTeamMember +// +// Add Team Member. +// +// Responses: +// 200: okResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) AddTeamMember(c *models.ReqContext) response.Response { cmd := models.AddTeamMemberCommand{} var err error @@ -93,7 +111,16 @@ func (hs *HTTPServer) AddTeamMember(c *models.ReqContext) response.Response { }) } -// PUT /:teamId/members/:userId +// swagger:route PUT /teams/{team_id}/members/{user_id} teams updateTeamMember +// +// Update Team Member. +// +// Responses: +// 200: okResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) UpdateTeamMember(c *models.ReqContext) response.Response { cmd := models.UpdateTeamMemberCommand{} if err := web.Bind(c.Req, &cmd); err != nil { @@ -140,7 +167,16 @@ func getPermissionName(permission models.PermissionType) string { return permissionName } -// DELETE /api/teams/:teamId/members/:userId +// swagger:route DELETE /teams/{team_id}/members/{user_id} teams removeTeamMember +// +// Remove Member From Team. +// +// Responses: +// 200: okResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) RemoveTeamMember(c *models.ReqContext) response.Response { orgId := c.OrgId teamId, err := strconv.ParseInt(web.Params(c.Req)[":teamId"], 10, 64) @@ -183,3 +219,50 @@ var addOrUpdateTeamMember = func(ctx context.Context, resourcePermissionService } return nil } + +// swagger:parameters getTeamMembers +type GetTeamMembersParams struct { + // in:path + // required:true + TeamID string `json:"team_id"` +} + +// swagger:parameters addTeamMember +type AddTeamMemberParams struct { + // in:body + // required:true + Body models.AddTeamMemberCommand `json:"body"` + // in:path + // required:true + TeamID string `json:"team_id"` +} + +// swagger:parameters updateTeamMember +type UpdateTeamMemberParams struct { + // in:body + // required:true + Body models.UpdateTeamMemberCommand `json:"body"` + // in:path + // required:true + TeamID string `json:"team_id"` + // in:path + // required:true + UserID int64 `json:"user_id"` +} + +// swagger:parameters removeTeamMember +type RemoveTeamMemberParams struct { + // in:path + // required:true + TeamID string `json:"team_id"` + // in:path + // required:true + UserID int64 `json:"user_id"` +} + +// swagger:response getTeamMembersResponse +type GetTeamMembersResponse struct { + // The response message + // in: body + Body []*models.TeamMemberDTO `json:"body"` +} diff --git a/pkg/api/user.go b/pkg/api/user.go index da36550cc73..41c9f7d2ace 100644 --- a/pkg/api/user.go +++ b/pkg/api/user.go @@ -15,12 +15,30 @@ import ( "github.com/grafana/grafana/pkg/web" ) -// GET /api/user (current authenticated user) +// swagger:route GET /user signed_in_user getSignedInUser +// +// Get (current authenticated user) +// +// Responses: +// 200: userResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) GetSignedInUser(c *models.ReqContext) response.Response { return hs.getUserUserProfile(c, c.UserId) } -// GET /api/users/:id +// swagger:route GET /users/{user_id} users getUserByID +// +// Get user by id. +// +// Responses: +// 200: userResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) GetUserByID(c *models.ReqContext) response.Response { id, err := strconv.ParseInt(web.Params(c.Req)[":id"], 10, 64) if err != nil { @@ -53,7 +71,16 @@ func (hs *HTTPServer) getUserUserProfile(c *models.ReqContext, userID int64) res return response.JSON(http.StatusOK, query.Result) } -// GET /api/users/lookup +// swagger:route GET /users/lookup users getUserByLoginOrEmail +// +// Get user by login or email. +// +// Responses: +// 200: userResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) GetUserByLoginOrEmail(c *models.ReqContext) response.Response { query := models.GetUserByLoginQuery{LoginOrEmail: c.Query("loginOrEmail")} if err := hs.SQLStore.GetUserByLogin(c.Req.Context(), &query); err != nil { @@ -77,7 +104,15 @@ func (hs *HTTPServer) GetUserByLoginOrEmail(c *models.ReqContext) response.Respo return response.JSON(http.StatusOK, &result) } -// POST /api/user +// swagger:route PUT /user signed_in_user updateSignedInUser +// +// Update signed in User. +// +// Responses: +// 200: okResponse +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) UpdateSignedInUser(c *models.ReqContext) response.Response { cmd := models.UpdateUserCommand{} if err := web.Bind(c.Req, &cmd); err != nil { @@ -95,7 +130,18 @@ func (hs *HTTPServer) UpdateSignedInUser(c *models.ReqContext) response.Response return hs.handleUpdateUser(c.Req.Context(), cmd) } -// POST /api/users/:id +// swagger:route PUT /users/{user_id} users updateUser +// +// Update user. +// +// Update the user identified by id. +// +// Responses: +// 200: okResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) UpdateUser(c *models.ReqContext) response.Response { cmd := models.UpdateUserCommand{} var err error @@ -151,17 +197,51 @@ func (hs *HTTPServer) handleUpdateUser(ctx context.Context, cmd models.UpdateUse return response.Success("User updated") } -// GET /api/user/orgs +// swagger:route GET /user/orgs signed_in_user getSignedInUserOrgList +// +// Organizations of the actual User. +// +// Return a list of all organizations of the current user. +// +// Security: +// - basic: +// +// Responses: +// 200: getSignedInUserOrgListResponse +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) GetSignedInUserOrgList(c *models.ReqContext) response.Response { return hs.getUserOrgList(c.Req.Context(), c.UserId) } -// GET /api/user/teams +// swagger:route GET /user/teams signed_in_user getSignedInUserTeamList +// +// Teams that the actual User is member of. +// +// Return a list of all teams that the current user is member of. +// +// Responses: +// 200: getSignedInUserTeamListResponse +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) GetSignedInUserTeamList(c *models.ReqContext) response.Response { return hs.getUserTeamList(c, c.OrgId, c.UserId) } -// GET /api/users/:id/teams +// swagger:route GET /users/{user_id}/teams users getUserTeams +// +// Get teams for user. +// +// Get teams for user identified by id. +// +// Responses: +// 200: getUserTeamsResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) GetUserTeams(c *models.ReqContext) response.Response { id, err := strconv.ParseInt(web.Params(c.Req)[":id"], 10, 64) if err != nil { @@ -183,7 +263,18 @@ func (hs *HTTPServer) getUserTeamList(c *models.ReqContext, orgID int64, userID return response.JSON(http.StatusOK, query.Result) } -// GET /api/users/:id/orgs +// swagger:route GET /users/{user_id}/orgs users getUserOrgList +// +// Get organizations for user. +// +// Get organizations for user identified by id. +// +// Responses: +// 200: getUserOrgListResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (hs *HTTPServer) GetUserOrgList(c *models.ReqContext) response.Response { id, err := strconv.ParseInt(web.Params(c.Req)[":id"], 10, 64) if err != nil { @@ -220,7 +311,18 @@ func (hs *HTTPServer) validateUsingOrg(ctx context.Context, userID int64, orgID return valid } -// POST /api/user/using/:id +// swagger:route POST /user/using/{org_id} signed_in_user userSetUsingOrg +// +// Switch user context for signed in user. +// +// Switch user context to the given organization. +// +// Responses: +// 200: okResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) UserSetUsingOrg(c *models.ReqContext) response.Response { orgID, err := strconv.ParseInt(web.Params(c.Req)[":id"], 10, 64) if err != nil { @@ -261,6 +363,21 @@ func (hs *HTTPServer) ChangeActiveOrgAndRedirectToHome(c *models.ReqContext) { c.Redirect(hs.Cfg.AppSubURL + "/") } +// swagger:route PUT /user/password signed_in_user changeUserPassword +// +// Change Password. +// +// Changes the password for the user. +// +// Security: +// - basic: +// +// Responses: +// 200: okResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) ChangeUserPassword(c *models.ReqContext) response.Response { cmd := models.ChangeUserPasswordCommand{} if err := web.Bind(c.Req, &cmd); err != nil { @@ -307,6 +424,15 @@ func redirectToChangePassword(c *models.ReqContext) { c.Redirect("/profile/password", 302) } +// swagger:route PUT /user/helpflags/{flag_id} signed_in_user setHelpFlag +// +// Set user help flag. +// +// Responses: +// 200: helpFlagResponse +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) SetHelpFlag(c *models.ReqContext) response.Response { flag, err := strconv.ParseInt(web.Params(c.Req)[":id"], 10, 64) if err != nil { @@ -328,6 +454,15 @@ func (hs *HTTPServer) SetHelpFlag(c *models.ReqContext) response.Response { return response.JSON(http.StatusOK, &util.DynMap{"message": "Help flag set", "helpFlags1": cmd.HelpFlags1}) } +// swagger:route GET /user/helpflags/clear signed_in_user clearHelpFlags +// +// Clear user help flag. +// +// Responses: +// 200: helpFlagResponse +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) ClearHelpFlags(c *models.ReqContext) response.Response { cmd := models.SetUserHelpFlagCommand{ UserId: c.UserId, @@ -361,3 +496,158 @@ func GetAuthProviderLabel(authModule string) string { return "OAuth" } } + +// swagger:parameters searchUsers +type SearchUsersParams struct { + // Limit the maximum number of users to return per page + // in:query + // required:false + // default:1000 + Limit int64 `json:"perpage"` + // Page index for starting fetching users + // in:query + // required:false + // default:1 + Page int64 `json:"page"` +} + +// swagger:parameters searchUsersWithPaging + +type SearchUsersWithPagingParams struct { + // Limit the maximum number of users to return per page + // in:query + // required:false + // default:1000 + Limit int64 `json:"perpage"` + // Page index for starting fetching users + // in:query + // required:false + // default:1 + Page int64 `json:"page"` + // Query allows return results where the query value is contained in one of the name, login or email fields. Query values with spaces need to be URL encoded e.g. query=Jane%20Doe + // in:query + // required:false + Query string `json:"query"` +} + +// swagger:parameters updateSignedInUser +type UpdateSignedInUserParams struct { + // To change the email, name, login, theme, provide another one. + // in:body + // required:true + Body models.UpdateUserCommand `json:"body"` +} + +// swagger:parameters userSetUsingOrg +type UserSetUsingOrgParams struct { + // in:path + // required:true + OrgID int64 `json:"org_id"` +} + +// swagger:parameters setHelpFlag +type SetHelpFlagParams struct { + // in:path + // required:true + FlagID string `json:"flag_id"` +} + +// swagger:parameters changeUserPassword +type ChangeUserPasswordParams struct { + // To change the email, name, login, theme, provide another one. + // in:body + // required:true + Body models.ChangeUserPasswordCommand `json:"body"` +} + +// swagger:parameters getUserByID +type GetUserByIDParams struct { + // in:path + // required:true + UserID int64 `json:"user_id"` +} + +// swagger:parameters getUserOrgList +type GetUserOrgListParams struct { + // in:path + // required:true + UserID int64 `json:"user_id"` +} + +// swagger:parameters getUserTeams +type GetUserTeamsParams struct { + // in:path + // required:true + UserID int64 `json:"user_id"` +} + +// swagger:parameters getUserByLoginOrEmail +type GetUserByLoginOrEmailParams struct { + // loginOrEmail of the user + // in:query + // required:true + LoginOrEmail string `json:"loginOrEmail"` +} + +// swagger:parameters updateUser +type UpdateUserParams struct { + // To change the email, name, login, theme, provide another one. + // in:body + // required:true + Body models.UpdateUserCommand `json:"body"` + // in:path + // required:true + UserID int64 `json:"user_id"` +} + +// swagger:response searchUsersResponse +type SearchUsersResponse struct { + // The response message + // in: body + Body models.SearchUserQueryResult `json:"body"` +} + +// swagger:response userResponse +type UserResponse struct { + // The response message + // in: body + Body models.UserProfileDTO `json:"body"` +} + +// swagger:response getUserOrgListResponse +type GetUserOrgListResponse struct { + // The response message + // in: body + Body []*models.UserOrgDTO `json:"body"` +} + +// swagger:response getSignedInUserOrgListResponse +type GetSignedInUserOrgListResponse struct { + // The response message + // in: body + Body []*models.UserOrgDTO `json:"body"` +} + +// swagger:response getUserTeamsResponse +type GetUserTeamsResponse struct { + // The response message + // in: body + Body []*models.TeamDTO `json:"body"` +} + +// swagger:response getSignedInUserTeamListResponse +type GetSignedInUserTeamListResponse struct { + // The response message + // in: body + Body []*models.TeamDTO `json:"body"` +} + +// swagger:response helpFlagResponse +type HelpFlagResponse struct { + // The response message + // in: body + Body struct { + HelpFlags1 int64 `json:"helpFlags1"` + Message string `json:"message"` + } `json:"body"` +} diff --git a/pkg/api/user_token.go b/pkg/api/user_token.go index 0546a5c76c6..74810d72e44 100644 --- a/pkg/api/user_token.go +++ b/pkg/api/user_token.go @@ -15,12 +15,33 @@ import ( "github.com/ua-parser/uap-go/uaparser" ) -// GET /api/user/auth-tokens +// swagger:route GET /user/auth-tokens signed_in_user getUserAuthTokens +// +// Auth tokens of the actual User. +// +// Return a list of all auth tokens (devices) that the actual user currently have logged in from. +// +// Responses: +// 200: getUserAuthTokensResponse +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) GetUserAuthTokens(c *models.ReqContext) response.Response { return hs.getUserAuthTokensInternal(c, c.UserId) } -// POST /api/user/revoke-auth-token +// swagger:route POST /user/revoke-auth-token signed_in_user revokeUserAuthToken +// +// Revoke an auth token of the actual User. +// +// Revokes the given auth token (device) for the actual user. User of issued auth token (device) will no longer be logged in and will be required to authenticate again upon next activity. +// +// Responses: +// 200: okResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (hs *HTTPServer) RevokeUserAuthToken(c *models.ReqContext) response.Response { cmd := models.RevokeAuthTokenCmd{} if err := web.Bind(c.Req, &cmd); err != nil { @@ -153,3 +174,16 @@ func (hs *HTTPServer) revokeUserAuthTokenInternal(c *models.ReqContext, userID i "message": "User auth token revoked", }) } + +// swagger:parameters revokeUserAuthToken +type RevokeUserAuthTokenParams struct { + // in:body + // required:true + Body models.RevokeAuthTokenCmd `json:"body"` +} + +// swagger:response getUserAuthTokensResponse +type GetUserAuthTokensResponse struct { + // in:body + Body []*models.UserToken `json:"body"` +} diff --git a/pkg/server/server.go b/pkg/server/server.go index c28cd9e1de8..22ffa134691 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -16,7 +16,6 @@ import ( "github.com/grafana/grafana/pkg/services/accesscontrol" "github.com/grafana/grafana/pkg/api" - _ "github.com/grafana/grafana/pkg/api/docs/definitions" _ "github.com/grafana/grafana/pkg/extensions" "github.com/grafana/grafana/pkg/infra/log" "github.com/grafana/grafana/pkg/infra/metrics" diff --git a/pkg/services/correlations/api.go b/pkg/services/correlations/api.go index eebe70e3272..8f28671d24d 100644 --- a/pkg/services/correlations/api.go +++ b/pkg/services/correlations/api.go @@ -24,7 +24,17 @@ func (s *CorrelationsService) registerAPIEndpoints() { }) } -// createHandler handles POST /datasources/uid/:uid/correlations +// swagger:route POST /datasources/uid/{sourceUID}/correlations correlations createCorrelation +// +// Add correlation. +// +// Responses: +// 200: createCorrelationResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (s *CorrelationsService) createHandler(c *models.ReqContext) response.Response { cmd := CreateCorrelationCommand{} if err := web.Bind(c.Req, &cmd); err != nil { @@ -46,10 +56,35 @@ func (s *CorrelationsService) createHandler(c *models.ReqContext) response.Respo return response.Error(http.StatusInternalServerError, "Failed to add correlation", err) } - return response.JSON(http.StatusOK, CreateCorrelationResponse{Result: correlation, Message: "Correlation created"}) + return response.JSON(http.StatusOK, CreateCorrelationResponseBody{Result: correlation, Message: "Correlation created"}) } -// deleteHandler handles DELETE /datasources/uid/:uid/correlations/:correlationUID +// swagger:parameters createCorrelation +type CreateCorrelationParams struct { + // in:body + // required:true + Body CreateCorrelationCommand `json:"body"` + // in:path + // required:true + SourceUID string `json:"sourceUID"` +} + +//swagger:response createCorrelationResponse +type CreateCorrelationResponse struct { + // in: body + Body CreateCorrelationResponseBody `json:"body"` +} + +// swagger:route DELETE /datasources/uid/{uid}/correlations/{correlationUID} correlations deleteCorrelation +// +// Delete a correlation. +// +// Responses: +// 200: deleteCorrelationResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (s *CorrelationsService) deleteHandler(c *models.ReqContext) response.Response { cmd := DeleteCorrelationCommand{ UID: web.Params(c.Req)[":correlationUID"], @@ -74,5 +109,21 @@ func (s *CorrelationsService) deleteHandler(c *models.ReqContext) response.Respo return response.Error(http.StatusInternalServerError, "Failed to delete correlation", err) } - return response.JSON(http.StatusOK, DeleteCorrelationResponse{Message: "Correlation deleted"}) + return response.JSON(http.StatusOK, DeleteCorrelationResponseBody{Message: "Correlation deleted"}) +} + +// swagger:parameters deleteCorrelation +type DeleteCorrelationParams struct { + // in:path + // required:true + DatasourceUID string `json:"uid"` + // in:path + // required:true + CorrelationUID string `json:"correlationUID"` +} + +//swagger:response deleteCorrelationResponse +type DeleteCorrelationResponse struct { + // in: body + Body DeleteCorrelationResponseBody `json:"body"` } diff --git a/pkg/services/correlations/models.go b/pkg/services/correlations/models.go index 8b09a7cc108..6838a9f0ef9 100644 --- a/pkg/services/correlations/models.go +++ b/pkg/services/correlations/models.go @@ -34,7 +34,7 @@ type Correlation struct { // CreateCorrelationResponse is the response struct for CreateCorrelationCommand // swagger:model -type CreateCorrelationResponse struct { +type CreateCorrelationResponseBody struct { Result Correlation `json:"result"` // example: Correlation created Message string `json:"message"` @@ -59,7 +59,7 @@ type CreateCorrelationCommand struct { } // swagger:model -type DeleteCorrelationResponse struct { +type DeleteCorrelationResponseBody struct { // example: Correlation deleted Message string `json:"message"` } diff --git a/pkg/services/dashboardimport/api/api.go b/pkg/services/dashboardimport/api/api.go index eca01ce5a5b..12691f8ed5e 100644 --- a/pkg/services/dashboardimport/api/api.go +++ b/pkg/services/dashboardimport/api/api.go @@ -43,6 +43,17 @@ func (api *ImportDashboardAPI) RegisterAPIEndpoints(routeRegister routing.RouteR }, middleware.ReqSignedIn) } +// swagger:route POST /dashboards/import dashboards importDashboard +// +// Import dashboard. +// +// Responses: +// 200: importDashboardResponse +// 400: badRequestError +// 401: unauthorisedError +// 412: preconditionFailedError +// 422: unprocessableEntityError +// 500: internalServerError func (api *ImportDashboardAPI) ImportDashboard(c *models.ReqContext) response.Response { req := dashboardimport.ImportDashboardRequest{} if err := web.Bind(c.Req, &req); err != nil { @@ -80,3 +91,16 @@ type quotaServiceFunc func(c *models.ReqContext, target string) (bool, error) func (fn quotaServiceFunc) QuotaReached(c *models.ReqContext, target string) (bool, error) { return fn(c, target) } + +// swagger:parameters importDashboard +type ImportDashboardParams struct { + // in:body + // required:true + Body dashboardimport.ImportDashboardRequest +} + +// swagger:response importDashboardResponse +type ImportDashboardResponse struct { + // in: body + Body dashboardimport.ImportDashboardResponse `json:"body"` +} diff --git a/pkg/services/libraryelements/api.go b/pkg/services/libraryelements/api.go index 8781d0cd0b6..18b17618785 100644 --- a/pkg/services/libraryelements/api.go +++ b/pkg/services/libraryelements/api.go @@ -24,7 +24,19 @@ func (l *LibraryElementService) registerAPIEndpoints() { }) } -// createHandler handles POST /api/library-elements. +// swagger:route POST /library-elements library_elements createLibraryElement +// +// Create library element. +// +// Creates a new library element. +// +// Responses: +// 200: getLibraryElementResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (l *LibraryElementService) createHandler(c *models.ReqContext) response.Response { cmd := CreateLibraryElementCommand{} if err := web.Bind(c.Req, &cmd); err != nil { @@ -61,7 +73,20 @@ func (l *LibraryElementService) createHandler(c *models.ReqContext) response.Res return response.JSON(http.StatusOK, LibraryElementResponse{Result: element}) } -// deleteHandler handles DELETE /api/library-elements/:uid. +// swagger:route DELETE /library-elements/{library_element_uid} library_elements deleteLibraryElementByUID +// +// Delete library element. +// +// Deletes an existing library element as specified by the UID. This operation cannot be reverted. +// You cannot delete a library element that is connected. This operation cannot be reverted. +// +// Responses: +// 200: okResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (l *LibraryElementService) deleteHandler(c *models.ReqContext) response.Response { id, err := l.deleteLibraryElement(c.Req.Context(), c.SignedInUser, web.Params(c.Req)[":uid"]) if err != nil { @@ -74,7 +99,17 @@ func (l *LibraryElementService) deleteHandler(c *models.ReqContext) response.Res }) } -// getHandler handles GET /api/library-elements/:uid. +// swagger:route GET /library-elements/{library_element_uid} library_elements getLibraryElementByUID +// +// Get library element by UID. +// +// Returns a library element with the given UID. +// +// Responses: +// 200: getLibraryElementResponse +// 401: unauthorisedError +// 404: notFoundError +// 500: internalServerError func (l *LibraryElementService) getHandler(c *models.ReqContext) response.Response { element, err := l.getLibraryElementByUid(c.Req.Context(), c.SignedInUser, web.Params(c.Req)[":uid"]) if err != nil { @@ -84,7 +119,18 @@ func (l *LibraryElementService) getHandler(c *models.ReqContext) response.Respon return response.JSON(http.StatusOK, LibraryElementResponse{Result: element}) } -// getAllHandler handles GET /api/library-elements/. +// swagger:route GET /library-elements library_elements getLibraryElements +// +// Get all library elements. +// +// Returns a list of all library elements the authenticated user has permission to view. +// Use the `perPage` query parameter to control the maximum number of library elements returned; the default limit is `100`. +// You can also use the `page` query parameter to fetch library elements from any page other than the first one. +// +// Responses: +// 200: getLibraryElementsResponse +// 401: unauthorisedError +// 500: internalServerError func (l *LibraryElementService) getAllHandler(c *models.ReqContext) response.Response { query := searchLibraryElementsQuery{ perPage: c.QueryInt("perPage"), @@ -104,7 +150,20 @@ func (l *LibraryElementService) getAllHandler(c *models.ReqContext) response.Res return response.JSON(http.StatusOK, LibraryElementSearchResponse{Result: elementsResult}) } -// patchHandler handles PATCH /api/library-elements/:uid +// swagger:route PATCH /library-elements/{library_element_uid} library_elements updateLibraryElement +// +// Update library element. +// +// Updates an existing library element identified by uid. +// +// Responses: +// 200: getLibraryElementResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 412: preconditionFailedError +// 500: internalServerError func (l *LibraryElementService) patchHandler(c *models.ReqContext) response.Response { cmd := PatchLibraryElementCommand{} if err := web.Bind(c.Req, &cmd); err != nil { @@ -141,7 +200,17 @@ func (l *LibraryElementService) patchHandler(c *models.ReqContext) response.Resp return response.JSON(http.StatusOK, LibraryElementResponse{Result: element}) } -// getConnectionsHandler handles GET /api/library-panels/:uid/connections/. +// swagger:route GET /library-elements/{library_element_uid}/connections/ library_elements getLibraryElementConnections +// +// Get library element connections. +// +// Returns a list of connections for a library element based on the UID specified. +// +// Responses: +// 200: getLibraryElementConnectionsResponse +// 401: unauthorisedError +// 404: notFoundError +// 500: internalServerError func (l *LibraryElementService) getConnectionsHandler(c *models.ReqContext) response.Response { connections, err := l.getConnections(c.Req.Context(), c.SignedInUser, web.Params(c.Req)[":uid"]) if err != nil { @@ -151,7 +220,17 @@ func (l *LibraryElementService) getConnectionsHandler(c *models.ReqContext) resp return response.JSON(http.StatusOK, LibraryElementConnectionsResponse{Result: connections}) } -// getByNameHandler handles GET /api/library-elements/name/:name/. +// swagger:route GET /library-elements/name/{library_element_name} library_elements getLibraryElementByName +// +// Get library element by name. +// +// Returns a library element with the given name. +// +// Responses: +// 200: getLibraryElementResponse +// 401: unauthorisedError +// 404: notFoundError +// 500: internalServerError func (l *LibraryElementService) getByNameHandler(c *models.ReqContext) response.Response { elements, err := l.getLibraryElementsByName(c.Req.Context(), c.SignedInUser, web.Params(c.Req)[":name"]) if err != nil { @@ -191,3 +270,119 @@ func toLibraryElementError(err error, message string) response.Response { } return response.Error(500, message, err) } + +// swagger:parameters getLibraryElementByUID getLibraryElementConnections +type LibraryElementByUID struct { + // in:path + // required:true + UID string `json:"library_element_uid"` +} + +// swagger:parameters getLibraryElementByUID +type GetLibraryElementByUIDParams struct { + // in:path + // required:true + UID string `json:"library_element_uid"` +} + +// swagger:parameters GetLibraryElementConnectionsParams +type GetLibraryElementConnectionsParams struct { + // in:path + // required:true + UID string `json:"library_element_uid"` +} + +// swagger:parameters deleteLibraryElementByUID +type DeleteLibraryElementByUIDParams struct { + // in:path + // required:true + UID string `json:"library_element_uid"` +} + +// swagger:parameters getLibraryElementByName +type LibraryElementByNameParams struct { + // in:path + // required:true + Name string `json:"library_element_name"` +} + +// swagger:parameters getLibraryElements +type GetLibraryElementsParams struct { + // Part of the name or description searched for. + // in:query + // required:false + SearchString string `json:"searchString"` + // Kind of element to search for. + // in:query + // required:false + // Description: + // * 1 - library panels + // * 2 - library variables + // enum: 1,2 + Kind int `json:"kind"` + // Sort order of elements. + // in:query + // required:false + // Description: + // * alpha-asc: ascending + // * alpha-desc: descending + // Enum: alpha-asc,alpha-desc + SortDirection string `json:"sortDirection"` + // A comma separated list of types to filter the elements by + // in:query + // required:false + TypeFilter string `json:"typeFilter"` + // Element UID to exclude from search results. + // in:query + // required:false + ExcludeUID string `json:"excludeUid"` + // A comma separated list of folder ID(s) to filter the elements by. + // in:query + // required:false + FolderFilter string `json:"folderFilter"` + // The number of results per page. + // in:query + // required:false + // default: 100 + PerPage int `json:"perPage"` + // The page for a set of records, given that only perPage records are returned at a time. Numbering starts at 1. + // in:query + // required:false + // default: 1 + Page int `json:"page"` +} + +// swagger:parameters createLibraryElement +type CreateLibraryElementParams struct { + // in:body + // required:true + Body CreateLibraryElementCommand `json:"body"` +} + +// swagger:parameters updateLibraryElement +type UpdateLibraryElementParam struct { + // in:body + // required:true + Body PatchLibraryElementCommand `json:"body"` + // in:path + // required:true + UID string `json:"library_element_uid"` +} + +// swagger:response getLibraryElementsResponse +type GetLibraryElementsResponse struct { + // in: body + Body LibraryElementSearchResponse `json:"body"` +} + +// swagger:response getLibraryElementResponse +type GetLibraryElementResponse struct { + // in: body + Body LibraryElementResponse `json:"body"` +} + +// swagger:response getLibraryElementConnectionsResponse +type GetLibraryElementConnectionsResponse struct { + // in: body + Body LibraryElementConnectionsResponse `json:"body"` +} diff --git a/pkg/services/queryhistory/api.go b/pkg/services/queryhistory/api.go index 58881377ac1..8b99fadb467 100644 --- a/pkg/services/queryhistory/api.go +++ b/pkg/services/queryhistory/api.go @@ -25,7 +25,17 @@ func (s *QueryHistoryService) registerAPIEndpoints() { }) } -// createHandler handles POST /api/query-history +// swagger:route POST /query-history query_history createQuery +// +// Add query to query history. +// +// Adds new query to query history. +// +// Responses: +// 200: getQueryHistoryResponse +// 400: badRequestError +// 401: unauthorisedError +// 500: internalServerError func (s *QueryHistoryService) createHandler(c *models.ReqContext) response.Response { cmd := CreateQueryInQueryHistoryCommand{} if err := web.Bind(c.Req, &cmd); err != nil { @@ -40,7 +50,18 @@ func (s *QueryHistoryService) createHandler(c *models.ReqContext) response.Respo return response.JSON(http.StatusOK, QueryHistoryResponse{Result: query}) } -// searchHandler handles GET /api/query-history +// swagger:route GET /query-history query_history searchQueries +// +// Query history search. +// +// Returns a list of queries in the query history that matches the search criteria. +// Query history search supports pagination. Use the `limit` parameter to control the maximum number of queries returned; the default limit is 100. +// You can also use the `page` query parameter to fetch queries from any page other than the first one. +// +// Responses: +// 200: getQueryHistorySearchResponse +// 401: unauthorisedError +// 500: internalServerError func (s *QueryHistoryService) searchHandler(c *models.ReqContext) response.Response { timeRange := legacydata.NewDataTimeRange(c.Query("from"), c.Query("to")) @@ -63,7 +84,16 @@ func (s *QueryHistoryService) searchHandler(c *models.ReqContext) response.Respo return response.JSON(http.StatusOK, QueryHistorySearchResponse{Result: result}) } -// deleteHandler handles DELETE /api/query-history/:uid +// swagger:route DELETE /query-history/{query_history_uid} query_history deleteQuery +// +// Delete query in query history. +// +// Deletes an existing query in query history as specified by the UID. This operation cannot be reverted. +// +// Responses: +// 200: getQueryHistoryDeleteQueryResponse +// 401: unauthorisedError +// 500: internalServerError func (s *QueryHistoryService) deleteHandler(c *models.ReqContext) response.Response { queryUID := web.Params(c.Req)[":uid"] if len(queryUID) > 0 && !util.IsValidShortUID(queryUID) { @@ -81,7 +111,17 @@ func (s *QueryHistoryService) deleteHandler(c *models.ReqContext) response.Respo }) } -// patchCommentHandler handles PATCH /api/query-history/:uid +// swagger:route PATCH /query-history/{query_history_uid} query_history patchQueryComment +// +// Update comment for query in query history. +// +// Updates comment for query in query history as specified by the UID. +// +// Responses: +// 200: getQueryHistoryResponse +// 400: badRequestError +// 401: unauthorisedError +// 500: internalServerError func (s *QueryHistoryService) patchCommentHandler(c *models.ReqContext) response.Response { queryUID := web.Params(c.Req)[":uid"] if len(queryUID) > 0 && !util.IsValidShortUID(queryUID) { @@ -101,7 +141,16 @@ func (s *QueryHistoryService) patchCommentHandler(c *models.ReqContext) response return response.JSON(http.StatusOK, QueryHistoryResponse{Result: query}) } -// starHandler handles POST /api/query-history/star/:uid +// swagger:route POST /query-history/star/{query_history_uid} query_history starQuery +// +// Add star to query in query history. +// +// Adds star to query in query history as specified by the UID. +// +// Responses: +// 200: getQueryHistoryResponse +// 401: unauthorisedError +// 500: internalServerError func (s *QueryHistoryService) starHandler(c *models.ReqContext) response.Response { queryUID := web.Params(c.Req)[":uid"] if len(queryUID) > 0 && !util.IsValidShortUID(queryUID) { @@ -116,7 +165,16 @@ func (s *QueryHistoryService) starHandler(c *models.ReqContext) response.Respons return response.JSON(http.StatusOK, QueryHistoryResponse{Result: query}) } -// starHandler handles DELETE /api/query-history/star/:uid +// swagger:route DELETE /query-history/star/{query_history_uid} query_history unstarQuery +// +// Remove star to query in query history. +// +// Removes star from query in query history as specified by the UID. +// +// Responses: +// 200: getQueryHistoryResponse +// 401: unauthorisedError +// 500: internalServerError func (s *QueryHistoryService) unstarHandler(c *models.ReqContext) response.Response { queryUID := web.Params(c.Req)[":uid"] if len(queryUID) > 0 && !util.IsValidShortUID(queryUID) { @@ -131,7 +189,17 @@ func (s *QueryHistoryService) unstarHandler(c *models.ReqContext) response.Respo return response.JSON(http.StatusOK, QueryHistoryResponse{Result: query}) } -// starHandler handles POST /api/query-history/migrate +// swagger:route POST /query-history/migrate query_history migrateQueries +// +// Migrate queries to query history. +// +// Adds multiple queries to query history. +// +// Responses: +// 200: getQueryHistoryMigrationResponse +// 400: badRequestError +// 401: unauthorisedError +// 500: internalServerError func (s *QueryHistoryService) migrateHandler(c *models.ReqContext) response.Response { cmd := MigrateQueriesToQueryHistoryCommand{} if err := web.Bind(c.Req, &cmd); err != nil { @@ -145,3 +213,95 @@ func (s *QueryHistoryService) migrateHandler(c *models.ReqContext) response.Resp return response.JSON(http.StatusOK, QueryHistoryMigrationResponse{Message: "Query history successfully migrated", TotalCount: totalCount, StarredCount: starredCount}) } + +// swagger:parameters starQuery patchQueryComment deleteQuery unstarQuery +type QueryHistoryByUID struct { + // in:path + // required:true + UID string `json:"query_history_uid"` +} + +// swagger:parameters searchQueries +type SearchQueriesParams struct { + // List of data source UIDs to search for + // in:query + // required: false + // type: array + // collectionFormat: multi + DatasourceUid []string `json:"datasourceUid"` + // Text inside query or comments that is searched for + // in:query + // required: false + SearchString string `json:"searchString"` + // Flag indicating if only starred queries should be returned + // in:query + // required: false + OnlyStarred bool `json:"onlyStarred"` + // Sort method + // in:query + // required: false + // default: time-desc + // Enum: time-desc,time-asc + Sort string `json:"sort"` + // Use this parameter to access hits beyond limit. Numbering starts at 1. limit param acts as page size. + // in:query + // required: false + Page int `json:"page"` + // Limit the number of returned results + // in:query + // required: false + Limit int `json:"limit"` + // From range for the query history search + // in:query + // required: false + From int64 `json:"from"` + // To range for the query history search + // in:query + // required: false + To int64 `json:"to"` +} + +// swagger:parameters createQuery +type CreateQueryParams struct { + // in:body + // required:true + Body CreateQueryInQueryHistoryCommand `json:"body"` +} + +// swagger:parameters patchQueryComment +type PatchQueryCommentParams struct { + // in:body + // required:true + Body PatchQueryCommentInQueryHistoryCommand `json:"body"` +} + +// swagger:parameters migrateQueries +type MigrateQueriesParams struct { + // in:body + // required:true + Body MigrateQueriesToQueryHistoryCommand `json:"body"` +} + +//swagger:response getQueryHistorySearchResponse +type GetQueryHistorySearchResponse struct { + // in: body + Body QueryHistorySearchResponse `json:"body"` +} + +// swagger:response getQueryHistoryResponse +type GetQueryHistoryResponse struct { + // in: body + Body QueryHistoryResponse `json:"body"` +} + +// swagger:response getQueryHistoryDeleteQueryResponse +type GetQueryHistoryDeleteQueryResponse struct { + // in: body + Body QueryHistoryDeleteQueryResponse `json:"body"` +} + +// swagger:response getQueryHistoryMigrationResponse +type GetQueryHistoryMigrationResponse struct { + // in: body + Body QueryHistoryMigrationResponse `json:"body"` +} diff --git a/pkg/services/searchusers/searchusers.go b/pkg/services/searchusers/searchusers.go index 78b59735c1d..1a0ca92d9de 100644 --- a/pkg/services/searchusers/searchusers.go +++ b/pkg/services/searchusers/searchusers.go @@ -23,6 +23,17 @@ func ProvideUsersService(sqlStore sqlstore.Store, searchUserFilter models.Search return &OSSService{sqlStore: sqlStore, searchUserFilter: searchUserFilter} } +// swagger:route GET /users users searchUsers +// +// Get users. +// +// Returns all users that the authenticated user has permission to view, admin permission required. +// +// Responses: +// 200: searchUsersResponse +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (s *OSSService) SearchUsers(c *models.ReqContext) response.Response { query, err := s.SearchUser(c) if err != nil { @@ -32,6 +43,16 @@ func (s *OSSService) SearchUsers(c *models.ReqContext) response.Response { return response.JSON(http.StatusOK, query.Result.Users) } +// swagger:route GET /users/search users searchUsersWithPaging +// +// Get users with paging. +// +// Responses: +// 200: searchUsersResponse +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (s *OSSService) SearchUsersWithPaging(c *models.ReqContext) response.Response { query, err := s.SearchUser(c) if err != nil { diff --git a/pkg/services/serviceaccounts/api/api.go b/pkg/services/serviceaccounts/api/api.go index 3c9fb31a114..87a16c72bb9 100644 --- a/pkg/services/serviceaccounts/api/api.go +++ b/pkg/services/serviceaccounts/api/api.go @@ -80,7 +80,21 @@ func (api *ServiceAccountsAPI) RegisterAPIEndpoints() { }) } -// POST /api/serviceaccounts +// swagger:route POST /serviceaccounts service_accounts createServiceAccount +// +// Create service account +// +// Required permissions (See note in the [introduction](https://grafana.com/docs/grafana/latest/developers/http_api/serviceaccount/#service-account-api) for an explanation): +// action: `serviceaccounts:write` scope: `serviceaccounts:*` +// +// Requires basic authentication and that the authenticated user is a Grafana Admin. +// +// Responses: +// 201: createServiceAccountResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (api *ServiceAccountsAPI) CreateServiceAccount(c *models.ReqContext) response.Response { cmd := serviceaccounts.CreateServiceAccountForm{} if err := web.Bind(c.Req, &cmd); err != nil { @@ -117,7 +131,20 @@ func (api *ServiceAccountsAPI) CreateServiceAccount(c *models.ReqContext) respon return response.JSON(http.StatusCreated, serviceAccount) } -// GET /api/serviceaccounts/:serviceAccountId +// swagger:route GET /serviceaccounts/{serviceAccountId} service_accounts retrieveServiceAccount +// +// Get single serviceaccount by Id +// +// Required permissions (See note in the [introduction](https://grafana.com/docs/grafana/latest/developers/http_api/serviceaccount/#service-account-api) for an explanation): +// action: `serviceaccounts:read` scope: `serviceaccounts:id:1` (single service account) +// +// Responses: +// 200: retrieveServiceAccountResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (api *ServiceAccountsAPI) RetrieveServiceAccount(ctx *models.ReqContext) response.Response { scopeID, err := strconv.ParseInt(web.Params(ctx.Req)[":serviceAccountId"], 10, 64) if err != nil { @@ -148,7 +175,20 @@ func (api *ServiceAccountsAPI) RetrieveServiceAccount(ctx *models.ReqContext) re return response.JSON(http.StatusOK, serviceAccount) } -// PATCH /api/serviceaccounts/:serviceAccountId +// swagger:route PATCH /serviceaccounts/{serviceAccountId} service_accounts updateServiceAccount +// +// Update service account +// +// Required permissions (See note in the [introduction](https://grafana.com/docs/grafana/latest/developers/http_api/serviceaccount/#service-account-api) for an explanation): +// action: `serviceaccounts:write` scope: `serviceaccounts:id:1` (single service account) +// +// Responses: +// 200: updateServiceAccountResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (api *ServiceAccountsAPI) UpdateServiceAccount(c *models.ReqContext) response.Response { scopeID, err := strconv.ParseInt(web.Params(c.Req)[":serviceAccountId"], 10, 64) if err != nil { @@ -204,7 +244,19 @@ func (api *ServiceAccountsAPI) validateRole(r *models.RoleType, orgRole *models. return nil } -// DELETE /api/serviceaccounts/:serviceAccountId +// swagger:route DELETE /serviceaccounts/{serviceAccountId} service_accounts deleteServiceAccount +// +// Delete service account +// +// Required permissions (See note in the [introduction](https://grafana.com/docs/grafana/latest/developers/http_api/serviceaccount/#service-account-api) for an explanation): +// action: `serviceaccounts:delete` scope: `serviceaccounts:id:1` (single service account) +// +// Responses: +// 200: okResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (api *ServiceAccountsAPI) DeleteServiceAccount(ctx *models.ReqContext) response.Response { scopeID, err := strconv.ParseInt(web.Params(ctx.Req)[":serviceAccountId"], 10, 64) if err != nil { @@ -217,8 +269,18 @@ func (api *ServiceAccountsAPI) DeleteServiceAccount(ctx *models.ReqContext) resp return response.Success("Service account deleted") } -// SearchOrgServiceAccountsWithPaging is an HTTP handler to search for org users with paging. -// GET /api/serviceaccounts/search +// swagger:route GET /serviceaccounts/search service_accounts searchOrgServiceAccountsWithPaging +// +// Search service accounts with paging +// +// Required permissions (See note in the [introduction](https://grafana.com/docs/grafana/latest/developers/http_api/serviceaccount/#service-account-api) for an explanation): +// action: `serviceaccounts:read` scope: `serviceaccounts:*` +// +// Responses: +// 200: searchOrgServiceAccountsWithPagingResponse +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (api *ServiceAccountsAPI) SearchOrgServiceAccountsWithPaging(c *models.ReqContext) response.Response { ctx := c.Req.Context() perPage := c.QueryInt("perpage") @@ -336,3 +398,81 @@ func (api *ServiceAccountsAPI) getAccessControlMetadata(c *models.ReqContext, sa return accesscontrol.GetResourcesMetadata(c.Req.Context(), permissions, "serviceaccounts:id:", saIDs) } + +// swagger:parameters searchOrgServiceAccountsWithPaging +type SearchOrgServiceAccountsWithPagingParams struct { + // in:query + // required:false + Disabled bool `jsson:"disabled"` + // in:query + // required:false + ExpiredTokens bool `json:"expiredTokens"` + // It will return results where the query value is contained in one of the name. + // Query values with spaces need to be URL encoded. + // in:query + // required:false + Query string `json:"query"` + // The default value is 1000. + // in:query + // required:false + PerPage int `json:"perpage"` + // The default value is 1. + // in:query + // required:false + Page int `json:"page"` +} + +// swagger:parameters createServiceAccount +type CreateServiceAccountParams struct { + //in:body + Body serviceaccounts.CreateServiceAccountForm +} + +// swagger:parameters retrieveServiceAccount +type RetrieveServiceAccountParams struct { + // in:path + ServiceAccountId int64 `json:"serviceAccountId"` +} + +// swagger:parameters updateServiceAccount +type UpdateServiceAccountParams struct { + // in:path + ServiceAccountId int64 `json:"serviceAccountId"` + // in:body + Body serviceaccounts.UpdateServiceAccountForm +} + +// swagger:parameters deleteServiceAccount +type DeleteServiceAccountParams struct { + // in:path + ServiceAccountId int64 `json:"serviceAccountId"` +} + +// swagger:response searchOrgServiceAccountsWithPagingResponse +type SearchOrgServiceAccountsWithPagingResponse struct { + // in:body + Body *serviceaccounts.SearchServiceAccountsResult +} + +// swagger:response createServiceAccountResponse +type CreateServiceAccountResponse struct { + // in:body + Body *serviceaccounts.ServiceAccountDTO +} + +// swagger:response retrieveServiceAccountResponse +type RetrieveServiceAccountResponse struct { + // in:body + Body *serviceaccounts.ServiceAccountDTO +} + +// swagger:response updateServiceAccountResponse +type UpdateServiceAccountResponse struct { + // in:body + Body struct { + Message string `json:"message"` + ID int64 `json:"id"` + Name string `json:"name"` + ServiceAccount *serviceaccounts.ServiceAccountProfileDTO `json:"serviceaccount"` + } +} diff --git a/pkg/services/serviceaccounts/api/token.go b/pkg/services/serviceaccounts/api/token.go index 334b874ffe5..068e08d9820 100644 --- a/pkg/services/serviceaccounts/api/token.go +++ b/pkg/services/serviceaccounts/api/token.go @@ -48,7 +48,21 @@ func hasExpired(expiration *int64) bool { const sevenDaysAhead = 7 * 24 * time.Hour -// GET /api/serviceaccounts/:serviceAccountId/tokens +// swagger:route GET /serviceaccounts/{serviceAccountId}/tokens service_accounts listTokens +// +// Get service account tokens +// +// Required permissions (See note in the [introduction](https://grafana.com/docs/grafana/latest/developers/http_api/serviceaccount/#service-account-api) for an explanation): +// action: `serviceaccounts:read` scope: `global:serviceaccounts:id:1` (single service account) +// +// Requires basic authentication and that the authenticated user is a Grafana Admin. +// +// Responses: +// 200: listTokensResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 500: internalServerError func (api *ServiceAccountsAPI) ListTokens(ctx *models.ReqContext) response.Response { saID, err := strconv.ParseInt(web.Params(ctx.Req)[":serviceAccountId"], 10, 64) if err != nil { @@ -88,8 +102,21 @@ func (api *ServiceAccountsAPI) ListTokens(ctx *models.ReqContext) response.Respo return response.JSON(http.StatusOK, result) } +// swagger:route POST /serviceaccounts/{serviceAccountId}/tokens service_accounts createToken +// // CreateNewToken adds a token to a service account -// POST /api/serviceaccounts/:serviceAccountId/tokens +// +// Required permissions (See note in the [introduction](https://grafana.com/docs/grafana/latest/developers/http_api/serviceaccount/#service-account-api) for an explanation): +// action: `serviceaccounts:write` scope: `serviceaccounts:id:1` (single service account) +// +// Responses: +// 200: createTokenResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 409: conflictError +// 500: internalServerError func (api *ServiceAccountsAPI) CreateToken(c *models.ReqContext) response.Response { saID, err := strconv.ParseInt(web.Params(c.Req)[":serviceAccountId"], 10, 64) if err != nil { @@ -149,8 +176,22 @@ func (api *ServiceAccountsAPI) CreateToken(c *models.ReqContext) response.Respon return response.JSON(http.StatusOK, result) } +// swagger:route DELETE /serviceaccounts/{serviceAccountId}/tokens/{tokenId} service_accounts deleteToken +// // DeleteToken deletes service account tokens -// DELETE /api/serviceaccounts/:serviceAccountId/tokens/:tokenId +// +// Required permissions (See note in the [introduction](https://grafana.com/docs/grafana/latest/developers/http_api/serviceaccount/#service-account-api) for an explanation): +// action: `serviceaccounts:write` scope: `serviceaccounts:id:1` (single service account) +// +// Requires basic authentication and that the authenticated user is a Grafana Admin. +// +// Responses: +// 200: okResponse +// 400: badRequestError +// 401: unauthorisedError +// 403: forbiddenError +// 404: notFoundError +// 500: internalServerError func (api *ServiceAccountsAPI) DeleteToken(c *models.ReqContext) response.Response { saID, err := strconv.ParseInt(web.Params(c.Req)[":serviceAccountId"], 10, 64) if err != nil { @@ -185,3 +226,37 @@ func (api *ServiceAccountsAPI) DeleteToken(c *models.ReqContext) response.Respon return response.Success("Service account token deleted") } + +// swagger:parameters listTokens +type ListTokensParams struct { + // in:path + ServiceAccountId int64 `json:"serviceAccountId"` +} + +// swagger:parameters createToken +type CreateTokenParams struct { + // in:path + ServiceAccountId int64 `json:"serviceAccountId"` + // in:body + Body serviceaccounts.AddServiceAccountTokenCommand +} + +// swagger:parameters deleteToken +type DeleteTokenParams struct { + // in:path + TokenId int64 `json:"tokenId"` + // in:path + ServiceAccountId int64 `json:"serviceAccountId"` +} + +// swagger:response listTokensResponse +type ListTokensResponse struct { + // in:body + Body *TokenDTO +} + +// swagger:response createTokenResponse +type CreateTokenResponse struct { + // in:body + Body *dtos.NewApiKeyResult +} diff --git a/pkg/tests/api/correlations/correlations_create_test.go b/pkg/tests/api/correlations/correlations_create_test.go index b88b7e14160..8808c218040 100644 --- a/pkg/tests/api/correlations/correlations_create_test.go +++ b/pkg/tests/api/correlations/correlations_create_test.go @@ -198,7 +198,7 @@ func TestIntegrationCreateCorrelation(t *testing.T) { responseBody, err := ioutil.ReadAll(res.Body) require.NoError(t, err) - var response correlations.CreateCorrelationResponse + var response correlations.CreateCorrelationResponseBody err = json.Unmarshal(responseBody, &response) require.NoError(t, err) @@ -228,7 +228,7 @@ func TestIntegrationCreateCorrelation(t *testing.T) { responseBody, err := ioutil.ReadAll(res.Body) require.NoError(t, err) - var response correlations.CreateCorrelationResponse + var response correlations.CreateCorrelationResponseBody err = json.Unmarshal(responseBody, &response) require.NoError(t, err) diff --git a/pkg/tests/api/correlations/correlations_delete_test.go b/pkg/tests/api/correlations/correlations_delete_test.go index 068192c3dc6..2ac6f3861af 100644 --- a/pkg/tests/api/correlations/correlations_delete_test.go +++ b/pkg/tests/api/correlations/correlations_delete_test.go @@ -172,7 +172,7 @@ func TestIntegrationDeleteCorrelation(t *testing.T) { responseBody, err := ioutil.ReadAll(res.Body) require.NoError(t, err) - var response correlations.CreateCorrelationResponse + var response correlations.CreateCorrelationResponseBody err = json.Unmarshal(responseBody, &response) require.NoError(t, err) @@ -204,7 +204,7 @@ func TestIntegrationDeleteCorrelation(t *testing.T) { responseBody, err := ioutil.ReadAll(res.Body) require.NoError(t, err) - var response correlations.CreateCorrelationResponse + var response correlations.CreateCorrelationResponseBody err = json.Unmarshal(responseBody, &response) require.NoError(t, err) diff --git a/public/api-merged.json b/public/api-merged.json index 4868d168703..8d34e64124b 100644 --- a/public/api-merged.json +++ b/public/api-merged.json @@ -118,7 +118,7 @@ "description": "Gets all existing roles. The response contains all global and organization local roles, for the organization which user is signed in.\n\nYou need to have a permission with action `roles:list` and scope `roles:*`.", "tags": ["access_control", "enterprise"], "summary": "Get all roles.", - "operationId": "getAllRoles", + "operationId": "listRoles", "parameters": [ { "type": "boolean", @@ -128,7 +128,7 @@ ], "responses": { "200": { - "$ref": "#/responses/getAllRolesResponse" + "$ref": "#/responses/listRolesResponse" }, "403": { "$ref": "#/responses/forbiddenError" @@ -142,7 +142,7 @@ "description": "Creates a new custom role and maps given permissions to that role. Note that roles with the same prefix as Fixed Roles can’t be created.\n\nYou need to have a permission with action `roles:write` and scope `permissions:type:delegate`. `permissions:type:delegate`` scope ensures that users can only create custom roles with the same, or a subset of permissions which the user has.\nFor example, if a user does not have required permissions for creating users, they won’t be able to create a custom role which allows to do that. This is done to prevent escalation of privileges.", "tags": ["access_control", "enterprise"], "summary": "Create a new custom role.", - "operationId": "createRoleWithPermissions", + "operationId": "createRole", "parameters": [ { "name": "body", @@ -154,8 +154,8 @@ } ], "responses": { - "200": { - "$ref": "#/responses/getRoleResponse" + "201": { + "$ref": "#/responses/createRoleResponse" }, "400": { "$ref": "#/responses/badRequestError" @@ -596,11 +596,11 @@ "get": { "description": "You need to have a permission with action `ldap.status:read`.", "tags": ["ldap_debug"], - "summary": "Available to grafana admins.", - "operationId": "getLDAPSyncStatus", + "summary": "Returns the current state of the LDAP background sync integration", + "operationId": "getSyncStatus", "responses": { "200": { - "$ref": "#/responses/getLDAPSyncStatusResponse" + "$ref": "#/responses/getSyncStatusResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -624,7 +624,7 @@ "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `ldap.config:reload`.", "tags": ["admin_ldap"], "summary": "Reloads the LDAP configuration.", - "operationId": "reloadLDAP", + "operationId": "reloadLDAPCfg", "responses": { "200": { "$ref": "#/responses/okResponse" @@ -678,7 +678,7 @@ "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `ldap.user:sync`.", "tags": ["admin_ldap"], "summary": "Enables a single Grafana user to be synchronized against LDAP.", - "operationId": "syncLDAPUser", + "operationId": "postSyncUserWithLDAP", "parameters": [ { "type": "integer", @@ -714,7 +714,7 @@ "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `ldap.user:read`.", "tags": ["admin_ldap"], "summary": "Finds an user based on a username in LDAP. This helps illustrate how would the particular user be mapped in Grafana when synced.", - "operationId": "getLDAPUser", + "operationId": "getUserFromLDAP", "parameters": [ { "type": "string", @@ -793,33 +793,6 @@ } } }, - "/admin/provisioning/accesscontrol/reload": { - "post": { - "security": [ - { - "basic": [] - } - ], - "description": "Reloads the provisioning config files for access control again. It won’t return until the new provisioned entities are already stored in the database. In case of dashboards, it will stop polling for changes in dashboard files and then restart it with new configurations after returning.\nIf you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `provisioning:reload` and scope `provisioners:accesscontrol`.", - "tags": ["admin_provisioning"], - "summary": "Reload access control provisioning configurations.", - "operationId": "reloadProvisionedAccessControl", - "responses": { - "200": { - "$ref": "#/responses/okResponse" - }, - "401": { - "$ref": "#/responses/unauthorisedError" - }, - "403": { - "$ref": "#/responses/forbiddenError" - }, - "500": { - "$ref": "#/responses/internalServerError" - } - } - } - }, "/admin/provisioning/dashboards/reload": { "post": { "security": [ @@ -830,7 +803,7 @@ "description": "Reloads the provisioning config files for dashboards again. It won’t return until the new provisioned entities are already stored in the database. In case of dashboards, it will stop polling for changes in dashboard files and then restart it with new configurations after returning.\nIf you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `provisioning:reload` and scope `provisioners:dashboards`.", "tags": ["admin_provisioning"], "summary": "Reload dashboard provisioning configurations.", - "operationId": "reloadProvisionedDashboards", + "operationId": "adminProvisioningReloadDashboards", "responses": { "200": { "$ref": "#/responses/okResponse" @@ -857,7 +830,7 @@ "description": "Reloads the provisioning config files for datasources again. It won’t return until the new provisioned entities are already stored in the database. In case of dashboards, it will stop polling for changes in dashboard files and then restart it with new configurations after returning.\nIf you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `provisioning:reload` and scope `provisioners:datasources`.", "tags": ["admin_provisioning"], "summary": "Reload datasource provisioning configurations.", - "operationId": "reloadProvisionedDatasources", + "operationId": "adminProvisioningReloadDatasources", "responses": { "200": { "$ref": "#/responses/okResponse" @@ -884,7 +857,7 @@ "description": "Reloads the provisioning config files for legacy alert notifiers again. It won’t return until the new provisioned entities are already stored in the database. In case of dashboards, it will stop polling for changes in dashboard files and then restart it with new configurations after returning.\nIf you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `provisioning:reload` and scope `provisioners:notifications`.", "tags": ["admin_provisioning"], "summary": "Reload legacy alert notifier provisioning configurations.", - "operationId": "reloadProvisionedAlertNotifiers", + "operationId": "adminProvisioningReloadNotifications", "responses": { "200": { "$ref": "#/responses/okResponse" @@ -911,7 +884,7 @@ "description": "Reloads the provisioning config files for plugins again. It won’t return until the new provisioned entities are already stored in the database. In case of dashboards, it will stop polling for changes in dashboard files and then restart it with new configurations after returning.\nIf you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `provisioning:reload` and scope `provisioners:plugin`.", "tags": ["admin_provisioning"], "summary": "Reload plugin provisioning configurations.", - "operationId": "reloadProvisionedPlugins", + "operationId": "adminProvisioningReloadPlugins", "responses": { "200": { "$ref": "#/responses/okResponse" @@ -938,10 +911,10 @@ "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `settings:read` and scopes: `settings:*`, `settings:auth.saml:` and `settings:auth.saml:enabled` (property level).", "tags": ["admin"], "summary": "Fetch settings.", - "operationId": "getSettings", + "operationId": "adminGetSettings", "responses": { "200": { - "$ref": "#/responses/getSettingsResponse" + "$ref": "#/responses/adminGetSettingsResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -957,10 +930,10 @@ "description": "Only works with Basic Authentication (username and password). See introduction for an explanation.\nIf you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `server:stats:read`.", "tags": ["admin"], "summary": "Fetch Grafana Stats.", - "operationId": "getStats", + "operationId": "adminGetStats", "responses": { "200": { - "$ref": "#/responses/getStatsResponse" + "$ref": "#/responses/adminGetStatsResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -984,7 +957,7 @@ "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `users:create`.\nNote that OrgId is an optional parameter that can be used to assign a new user to a different organization when `auto_assign_org` is set to `true`.", "tags": ["admin_users"], "summary": "Create new user.", - "operationId": "createUser", + "operationId": "adminCreateUser", "parameters": [ { "name": "body", @@ -997,7 +970,7 @@ ], "responses": { "200": { - "$ref": "#/responses/createUserResponse" + "$ref": "#/responses/adminCreateUserResponse" }, "400": { "$ref": "#/responses/badRequestError" @@ -1027,7 +1000,7 @@ "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `users:delete` and scope `global.users:*`.", "tags": ["admin_users"], "summary": "Delete global User.", - "operationId": "deleteUser", + "operationId": "adminDeleteUser", "parameters": [ { "type": "integer", @@ -1066,7 +1039,7 @@ "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `users.authtoken:list` and scope `global.users:*`.", "tags": ["admin_users"], "summary": "Return a list of all auth tokens (devices) that the user currently have logged in from.", - "operationId": "getAuthTokens", + "operationId": "adminGetUserAuthTokens", "parameters": [ { "type": "integer", @@ -1078,7 +1051,7 @@ ], "responses": { "200": { - "$ref": "#/responses/getAuthTokensResponse" + "$ref": "#/responses/adminGetUserAuthTokensResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -1102,7 +1075,7 @@ "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `users:disable` and scope `global.users:1` (userIDScope).", "tags": ["admin_users"], "summary": "Disable user.", - "operationId": "disableUser", + "operationId": "adminDisableUser", "parameters": [ { "type": "integer", @@ -1141,7 +1114,7 @@ "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `users:enable` and scope `global.users:1` (userIDScope).", "tags": ["admin_users"], "summary": "Enable user.", - "operationId": "enableUser", + "operationId": "adminEnableUser", "parameters": [ { "type": "integer", @@ -1180,7 +1153,7 @@ "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `users.logout` and scope `global.users:*`.", "tags": ["admin_users"], "summary": "Logout user revokes all auth tokens (devices) for the user. User of issued auth tokens (devices) will no longer be logged in and will be required to authenticate again upon next activity.", - "operationId": "logoutUser", + "operationId": "adminLogoutUser", "parameters": [ { "type": "integer", @@ -1222,7 +1195,7 @@ "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `users.password:update` and scope `global.users:*`.", "tags": ["admin_users"], "summary": "Set password for user.", - "operationId": "setPassword", + "operationId": "adminUpdateUserPassword", "parameters": [ { "name": "body", @@ -1264,7 +1237,7 @@ "description": "Only works with Basic Authentication (username and password). See introduction for an explanation.\nIf you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `users.permissions:update` and scope `global.users:*`.", "tags": ["admin_users"], "summary": "Set permissions for user.", - "operationId": "setPermissions", + "operationId": "adminUpdateUserPermissions", "parameters": [ { "name": "body", @@ -1352,6 +1325,14 @@ "summary": "Update user quota.", "operationId": "updateUserQuota", "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/UpdateUserQuotaCmd" + } + }, { "type": "string", "name": "quota_target", @@ -1364,14 +1345,6 @@ "name": "user_id", "in": "path", "required": true - }, - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/UpdateUserQuotaCmd" - } } ], "responses": { @@ -1403,7 +1376,7 @@ "description": "Revokes the given auth token (device) for the user. User of issued auth token (device) will no longer be logged in and will be required to authenticate again upon next activity.\nIf you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `users.authtoken:update` and scope `global.users:*`.", "tags": ["admin_users"], "summary": "Revoke auth token for user.", - "operationId": "revokeAuthToken", + "operationId": "adminRevokeUserAuthToken", "parameters": [ { "name": "body", @@ -1503,10 +1476,10 @@ "description": "Returns all notification channels, but with less detailed information. Accessible by any authenticated user and is mainly used by providing alert notification channels in Grafana UI when configuring alert rule.", "tags": ["legacy_alerts_notification_channels"], "summary": "Get all notification channels (lookup)", - "operationId": "lookupAlertNotificationChannels", + "operationId": "getAlertNotificationLookup", "responses": { "200": { - "$ref": "#/responses/lookupAlertNotificationChannelsResponse" + "$ref": "#/responses/getAlertNotificationLookupResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -2078,7 +2051,7 @@ "description": "Creates an annotation in the Grafana database. The dashboardId and panelId fields are optional. If they are not specified then an organization annotation is created and can be queried in any dashboard that adds the Grafana annotations data source. When creating a region annotation include the timeEnd property.\nThe format for `time` and `timeEnd` should be epoch numbers in millisecond resolution.\nThe response for this HTTP request is slightly different in versions prior to v6.4. In prior versions you would also get an endId if you where creating a region. But in 6.4 regions are represented using a single event with time and timeEnd properties.", "tags": ["annotations"], "summary": "Create Annotation.", - "operationId": "createAnnotation", + "operationId": "postAnnotation", "parameters": [ { "name": "body", @@ -2091,7 +2064,7 @@ ], "responses": { "200": { - "$ref": "#/responses/createAnnotationResponse" + "$ref": "#/responses/postAnnotationResponse" }, "400": { "$ref": "#/responses/badRequestError" @@ -2113,7 +2086,7 @@ "description": "Creates an annotation by using Graphite-compatible event format. The `when` and `data` fields are optional. If `when` is not specified then the current time will be used as annotation’s timestamp. The `tags` field can also be in prior to Graphite `0.10.0` format (string with multiple tags being separated by a space).", "tags": ["annotations"], "summary": "Create Annotation in Graphite format.", - "operationId": "createGraphiteAnnotation", + "operationId": "postGraphiteAnnotation", "parameters": [ { "name": "body", @@ -2126,7 +2099,7 @@ ], "responses": { "200": { - "$ref": "#/responses/createAnnotationResponse" + "$ref": "#/responses/postAnnotationResponse" }, "400": { "$ref": "#/responses/badRequestError" @@ -2209,7 +2182,7 @@ "get": { "tags": ["annotations"], "summary": "Get Annotation by Id.", - "operationId": "getAnnotation", + "operationId": "getAnnotationByID", "parameters": [ { "type": "string", @@ -2220,7 +2193,7 @@ ], "responses": { "200": { - "$ref": "#/responses/getAnnotationResponse" + "$ref": "#/responses/getAnnotationByIDResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -2273,7 +2246,7 @@ "description": "Deletes the annotation that matches the specified ID.", "tags": ["annotations"], "summary": "Delete Annotation By ID.", - "operationId": "deleteAnnotation", + "operationId": "deleteAnnotationByID", "parameters": [ { "type": "string", @@ -3025,7 +2998,7 @@ "get": { "tags": ["snapshots"], "summary": "List snapshots.", - "operationId": "getSnapshots", + "operationId": "searchDashboardSnapshots", "parameters": [ { "type": "string", @@ -3044,7 +3017,7 @@ ], "responses": { "200": { - "$ref": "#/responses/getSnapshotsResponse" + "$ref": "#/responses/searchDashboardSnapshotsResponse" }, "500": { "$ref": "#/responses/internalServerError" @@ -3057,7 +3030,7 @@ "produces": ["application/json", "text/html"], "tags": ["dashboards"], "summary": "Perform diff on two dashboards.", - "operationId": "calcDashboardDiff", + "operationId": "calculateDashboardDiff", "parameters": [ { "name": "Body", @@ -3083,7 +3056,7 @@ ], "responses": { "200": { - "$ref": "#/responses/dashboardDiffResponse" + "$ref": "#/responses/calculateDashboardDiffResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -3161,10 +3134,10 @@ }, "/dashboards/id/{DashboardID}/permissions": { "get": { - "description": "Please refer to [updated API](#/dashboard_permissions/getDashboardPermissionsWithUid) instead", + "description": "Please refer to [updated API](#/dashboard_permissions/getDashboardPermissionsListByUID) instead", "tags": ["dashboard_permissions"], "summary": "Gets all existing permissions for the given dashboard.", - "operationId": "getDashboardPermissions", + "operationId": "getDashboardPermissionsListByID", "deprecated": true, "parameters": [ { @@ -3177,7 +3150,7 @@ ], "responses": { "200": { - "$ref": "#/responses/getDashboardPermissionsResponse" + "$ref": "#/responses/getDashboardPermissionsListResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -3194,10 +3167,10 @@ } }, "post": { - "description": "Please refer to [updated API](#/dashboard_permissions/postDashboardPermissionsWithUid) instead\n\nThis operation will remove existing permissions if they’re not included in the request.", + "description": "Please refer to [updated API](#/dashboard_permissions/updateDashboardPermissionsByUID) instead\n\nThis operation will remove existing permissions if they’re not included in the request.", "tags": ["dashboard_permissions"], "summary": "Updates permissions for a dashboard.", - "operationId": "postDashboardPermissions", + "operationId": "updateDashboardPermissionsByID", "deprecated": true, "parameters": [ { @@ -3243,16 +3216,9 @@ "description": "Please refer to [updated API](#/dashboard_versions/restoreDashboardVersionByUID) instead", "tags": ["dashboard_versions"], "summary": "Restore a dashboard to a given dashboard version.", - "operationId": "restoreDashboardVersion", + "operationId": "restoreDashboardVersionByID", "deprecated": true, "parameters": [ - { - "type": "integer", - "format": "int64", - "name": "DashboardID", - "in": "path", - "required": true - }, { "name": "Body", "in": "body", @@ -3260,6 +3226,13 @@ "schema": { "$ref": "#/definitions/RestoreDashboardVersionCommand" } + }, + { + "type": "integer", + "format": "int64", + "name": "DashboardID", + "in": "path", + "required": true } ], "responses": { @@ -3286,7 +3259,7 @@ "description": "Please refer to [updated API](#/dashboard_versions/getDashboardVersionsByUID) instead", "tags": ["dashboard_versions"], "summary": "Gets all existing versions for the dashboard.", - "operationId": "getDashboardVersions", + "operationId": "getDashboardVersionsByID", "deprecated": true, "parameters": [ { @@ -3295,22 +3268,6 @@ "name": "DashboardID", "in": "path", "required": true - }, - { - "type": "integer", - "format": "int64", - "default": 0, - "description": "Maximum number of results to return", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "format": "int64", - "default": 0, - "description": "Version to start from when returning queries", - "name": "start", - "in": "query" } ], "responses": { @@ -3337,7 +3294,7 @@ "description": "Please refer to [updated API](#/dashboard_versions/getDashboardVersionByUID) instead", "tags": ["dashboard_versions"], "summary": "Get a specific dashboard version.", - "operationId": "getDashboardVersion", + "operationId": "getDashboardVersionByID", "deprecated": true, "parameters": [ { @@ -3418,7 +3375,7 @@ "operationId": "getDashboardTags", "responses": { "200": { - "$ref": "#/responses/dashboardsTagsResponse" + "$ref": "#/responses/getDashboardsTagsResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -3525,7 +3482,7 @@ "get": { "tags": ["dashboard_permissions"], "summary": "Gets all existing permissions for the given dashboard.", - "operationId": "getDashboardPermissionsWithUid", + "operationId": "getDashboardPermissionsListByUID", "parameters": [ { "type": "string", @@ -3536,7 +3493,7 @@ ], "responses": { "200": { - "$ref": "#/responses/getDashboardPermissionsResponse" + "$ref": "#/responses/getDashboardPermissionsListResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -3556,7 +3513,7 @@ "description": "This operation will remove existing permissions if they’re not included in the request.", "tags": ["dashboard_permissions"], "summary": "Updates permissions for a dashboard.", - "operationId": "postDashboardPermissionsWithUid", + "operationId": "updateDashboardPermissionsByUID", "parameters": [ { "name": "Body", @@ -3601,12 +3558,6 @@ "summary": "Restore a dashboard to a given dashboard version using UID.", "operationId": "restoreDashboardVersionByUID", "parameters": [ - { - "type": "string", - "name": "uid", - "in": "path", - "required": true - }, { "name": "Body", "in": "body", @@ -3614,6 +3565,12 @@ "schema": { "$ref": "#/definitions/RestoreDashboardVersionCommand" } + }, + { + "type": "string", + "name": "uid", + "in": "path", + "required": true } ], "responses": { @@ -3690,15 +3647,15 @@ "operationId": "getDashboardVersionByUID", "parameters": [ { - "type": "string", - "name": "uid", + "type": "integer", + "format": "int64", + "name": "DashboardVersionID", "in": "path", "required": true }, { - "type": "integer", - "format": "int64", - "name": "DashboardVersionID", + "type": "string", + "name": "uid", "in": "path", "required": true } @@ -3727,10 +3684,10 @@ "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `datasources:read` and scope: `datasources:*`.", "tags": ["datasources"], "summary": "Get all data sources.", - "operationId": "getDatasources", + "operationId": "getDataSources", "responses": { "200": { - "$ref": "#/responses/getDatasourcesResponse" + "$ref": "#/responses/getDataSourcesResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -3747,7 +3704,7 @@ "description": "By defining `password` and `basicAuthPassword` under secureJsonData property\nGrafana encrypts them securely as an encrypted blob in the database.\nThe response then lists the encrypted fields under secureJsonFields.\n\nIf you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `datasources:create`", "tags": ["datasources"], "summary": "Create a data source.", - "operationId": "addDatasource", + "operationId": "addDataSource", "parameters": [ { "name": "Body", @@ -3782,7 +3739,7 @@ "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `datasources:read` and scopes: `datasources:*`, `datasources:name:*` and `datasources:name:test_datasource` (single data source).", "tags": ["datasources"], "summary": "Get data source Id by Name.", - "operationId": "getDatasourceIdByName", + "operationId": "getDataSourceIdByName", "parameters": [ { "type": "string", @@ -3793,7 +3750,7 @@ ], "responses": { "200": { - "$ref": "#/responses/getDatasourceIDresponse" + "$ref": "#/responses/getDataSourceIDResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -3815,7 +3772,7 @@ "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `datasources:read` and scopes: `datasources:*`, `datasources:name:*` and `datasources:name:test_datasource` (single data source).", "tags": ["datasources"], "summary": "Get a single data source by Name.", - "operationId": "getDatasourceByName", + "operationId": "getDataSourceByName", "parameters": [ { "type": "string", @@ -3826,7 +3783,7 @@ ], "responses": { "200": { - "$ref": "#/responses/getDatasourceResponse" + "$ref": "#/responses/getDataSourceResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -3843,7 +3800,7 @@ "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `datasources:delete` and scopes: `datasources:*`, `datasources:name:*` and `datasources:name:test_datasource` (single data source).", "tags": ["datasources"], "summary": "Delete an existing data source by name.", - "operationId": "deleteDatasourceByName", + "operationId": "deleteDataSourceByName", "parameters": [ { "type": "string", @@ -3854,7 +3811,7 @@ ], "responses": { "200": { - "$ref": "#/responses/deleteDatasourceByNameResponse" + "$ref": "#/responses/deleteDataSourceByNameResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -4188,7 +4145,7 @@ "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `datasources:read` and scopes: `datasources:*`, `datasources:uid:*` and `datasources:uid:kLtEtcRGk` (single data source).", "tags": ["datasources"], "summary": "Get a single data source by UID.", - "operationId": "getDatasourceByUID", + "operationId": "getDataSourceByUID", "parameters": [ { "type": "string", @@ -4199,7 +4156,7 @@ ], "responses": { "200": { - "$ref": "#/responses/getDatasourceResponse" + "$ref": "#/responses/getDataSourceResponse" }, "400": { "$ref": "#/responses/badRequestError" @@ -4222,7 +4179,7 @@ "description": "Similar to creating a data source, `password` and `basicAuthPassword` should be defined under\nsecureJsonData in order to be stored securely as an encrypted blob in the database. Then, the\nencrypted fields are listed under secureJsonFields section in the response.\n\nIf you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `datasources:write` and scopes: `datasources:*`, `datasources:uid:*` and `datasources:uid:1` (single data source).", "tags": ["datasources"], "summary": "Update an existing data source.", - "operationId": "updateDatasourceByUID", + "operationId": "updateDataSourceByUID", "parameters": [ { "name": "Body", @@ -4258,7 +4215,7 @@ "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `datasources:delete` and scopes: `datasources:*`, `datasources:uid:*` and `datasources:uid:kLtEtcRGk` (single data source).", "tags": ["datasources"], "summary": "Delete an existing data source by UID.", - "operationId": "deleteDatasourceByUID", + "operationId": "deleteDataSourceByUID", "parameters": [ { "type": "string", @@ -4327,8 +4284,8 @@ "/datasources/uid/{uid}/health": { "get": { "tags": ["datasources"], - "summary": "Check data source health by Id.", - "operationId": "checkDatasourceHealth", + "summary": "Sends a health check request to the plugin datasource identified by the UID.", + "operationId": "checkDatasourceHealthWithUID", "parameters": [ { "type": "string", @@ -4360,17 +4317,17 @@ "get": { "tags": ["datasources"], "summary": "Fetch data source resources.", - "operationId": "fetchDatasourceResources", + "operationId": "callDatasourceResourceWithUID", "parameters": [ { "type": "string", - "name": "uid", + "name": "datasource_proxy_route", "in": "path", "required": true }, { "type": "string", - "name": "datasource_proxy_route", + "name": "uid", "in": "path", "required": true } @@ -4474,7 +4431,7 @@ "description": "Gets all existing permissions for the data source with the given id.\n\nYou need to have a permission with action `datasources.permissions:read` and scopes `datasources:*`, `datasources:id:*`, `datasources:id:1` (single data source).", "tags": ["datasource_permissions", "enterprise"], "summary": "Get permissions for a data source.", - "operationId": "getPermissions", + "operationId": "getAllPermissions", "parameters": [ { "type": "string", @@ -4485,7 +4442,61 @@ ], "responses": { "200": { - "$ref": "#/responses/getPermissionseResponse" + "$ref": "#/responses/getAllPermissionseResponse" + }, + "401": { + "$ref": "#/responses/unauthorisedError" + }, + "403": { + "$ref": "#/responses/forbiddenError" + }, + "404": { + "$ref": "#/responses/notFoundError" + }, + "500": { + "$ref": "#/responses/internalServerError" + } + } + }, + "post": { + "description": "You need to have a permission with action `datasources.permissions:read` and scopes `datasources:*`, `datasources:id:*`, `datasources:id:1` (single data source).", + "tags": ["datasource_permissions", "enterprise"], + "summary": "Add permissions for a data source.", + "operationId": "addPermission", + "parameters": [ + { + "type": "integer", + "format": "int64", + "name": "userId", + "in": "query" + }, + { + "type": "integer", + "format": "int64", + "name": "teamId", + "in": "query" + }, + { + "type": "string", + "name": "builtinRole", + "in": "query" + }, + { + "type": "integer", + "format": "int64", + "name": "permission", + "in": "query" + }, + { + "type": "string", + "name": "datasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/addPermissionResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -4534,19 +4545,16 @@ }, "404": { "$ref": "#/responses/notFoundError" - }, - "500": { - "$ref": "#/responses/internalServerError" } } } }, "/datasources/{id}": { "get": { - "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `datasources:read` and scopes: `datasources:*`, `datasources:id:*` and `datasources:id:1` (single data source).\n\nPlease refer to [updated API](#/datasources/getDatasourceByUID) instead", + "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `datasources:read` and scopes: `datasources:*`, `datasources:id:*` and `datasources:id:1` (single data source).\n\nPlease refer to [updated API](#/datasources/getDataSourceByUID) instead", "tags": ["datasources"], "summary": "Get a single data source by Id.", - "operationId": "getDatasourceByID", + "operationId": "getDataSourceByID", "deprecated": true, "parameters": [ { @@ -4558,7 +4566,7 @@ ], "responses": { "200": { - "$ref": "#/responses/getDatasourceResponse" + "$ref": "#/responses/getDataSourceResponse" }, "400": { "$ref": "#/responses/badRequestError" @@ -4578,10 +4586,10 @@ } }, "put": { - "description": "Similar to creating a data source, `password` and `basicAuthPassword` should be defined under\nsecureJsonData in order to be stored securely as an encrypted blob in the database. Then, the\nencrypted fields are listed under secureJsonFields section in the response.\n\nIf you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `datasources:write` and scopes: `datasources:*`, `datasources:id:*` and `datasources:id:1` (single data source).\n\nPlease refer to [updated API](#/datasources/updateDatasourceByUID) instead", + "description": "Similar to creating a data source, `password` and `basicAuthPassword` should be defined under\nsecureJsonData in order to be stored securely as an encrypted blob in the database. Then, the\nencrypted fields are listed under secureJsonFields section in the response.\n\nIf you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `datasources:write` and scopes: `datasources:*`, `datasources:id:*` and `datasources:id:1` (single data source).\n\nPlease refer to [updated API](#/datasources/updateDataSourceByUID) instead", "tags": ["datasources"], "summary": "Update an existing data source by its sequential ID.", - "operationId": "updateDatasourceByID", + "operationId": "updateDataSourceByID", "deprecated": true, "parameters": [ { @@ -4615,10 +4623,10 @@ } }, "delete": { - "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `datasources:delete` and scopes: `datasources:*`, `datasources:id:*` and `datasources:id:1` (single data source).\n\nPlease refer to [updated API](#/datasources/deleteDatasourceByUID) instead", + "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `datasources:delete` and scopes: `datasources:*`, `datasources:id:*` and `datasources:id:1` (single data source).\n\nPlease refer to [updated API](#/datasources/deleteDataSourceByUID) instead", "tags": ["datasources"], "summary": "Delete an existing data source by id.", - "operationId": "deleteDatasourceByID", + "operationId": "deleteDataSourceByID", "deprecated": true, "parameters": [ { @@ -4649,9 +4657,9 @@ }, "/datasources/{id}/health": { "get": { - "description": "Please refer to [updated API](#/datasources/checkDatasourceHealth) instead", + "description": "Please refer to [updated API](#/datasources/checkDatasourceHealthWithUID) instead", "tags": ["datasources"], - "summary": "Check data source health by Id.", + "summary": "Sends a health check request to the plugin datasource identified by the ID.", "operationId": "checkDatasourceHealthByID", "deprecated": true, "parameters": [ @@ -4683,21 +4691,21 @@ }, "/datasources/{id}/resources/{datasource_proxy_route}": { "get": { - "description": "Please refer to [updated API](#/datasources/fetchDatasourceResources) instead", + "description": "Please refer to [updated API](#/datasources/callDatasourceResourceWithUID) instead", "tags": ["datasources"], "summary": "Fetch data source resources by Id.", - "operationId": "fetchDatasourceResourcesByID", + "operationId": "callDatasourceResourceByID", "deprecated": true, "parameters": [ { "type": "string", - "name": "id", + "name": "datasource_proxy_route", "in": "path", "required": true }, { "type": "string", - "name": "datasource_proxy_route", + "name": "id", "in": "path", "required": true } @@ -4728,7 +4736,7 @@ "post": { "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `datasources:query`.", "tags": ["ds"], - "summary": "Query metrics with expressions", + "summary": "DataSource query metrics with expressions", "operationId": "queryMetricsWithExpressions", "parameters": [ { @@ -4742,10 +4750,10 @@ ], "responses": { "200": { - "$ref": "#/responses/queryDataResponse" + "$ref": "#/responses/queryMetricsWithExpressionsRespons" }, "207": { - "$ref": "#/responses/queryDataResponse" + "$ref": "#/responses/queryMetricsWithExpressionsRespons" }, "400": { "$ref": "#/responses/badRequestError" @@ -4993,7 +5001,7 @@ "get": { "tags": ["folder_permissions"], "summary": "Gets all existing permissions for the folder with the given `uid`.", - "operationId": "getFolderPermissions", + "operationId": "getFolderPermissionList", "parameters": [ { "type": "string", @@ -5004,7 +5012,7 @@ ], "responses": { "200": { - "$ref": "#/responses/getDashboardPermissionsResponse" + "$ref": "#/responses/getFolderPermissionListResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -5344,10 +5352,10 @@ "get": { "tags": ["licensing", "enterprise"], "summary": "Check license availability.", - "operationId": "getLicenseStatus", + "operationId": "getStatus", "responses": { "200": { - "$ref": "#/responses/getLicenseStatusResponse" + "$ref": "#/responses/getStatusResponse" } } } @@ -5503,24 +5511,6 @@ } } }, - "/login/saml": { - "get": { - "tags": ["saml", "enterprise"], - "summary": "It initiates the login flow by redirecting the user to the IdP.", - "operationId": "getSAMLLogin", - "responses": { - "302": { - "description": "(empty)" - }, - "404": { - "$ref": "#/responses/notFoundError" - }, - "500": { - "$ref": "#/responses/internalServerError" - } - } - } - }, "/logout/saml": { "get": { "tags": ["saml", "enterprise"], @@ -5542,11 +5532,11 @@ "/org": { "get": { "description": "Get current Organization", - "tags": ["current_org_details"], - "operationId": "getOrg", + "tags": ["org"], + "operationId": "getCurrentOrg", "responses": { "200": { - "$ref": "#/responses/getOrgResponse" + "$ref": "#/responses/getCurrentOrgResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -5560,9 +5550,9 @@ } }, "put": { - "tags": ["current_org_details"], + "tags": ["org"], "summary": "Update current Organization.", - "operationId": "updateOrg", + "operationId": "updateCurrentOrg", "parameters": [ { "name": "body", @@ -5594,9 +5584,9 @@ }, "/org/address": { "put": { - "tags": ["current_org_details"], + "tags": ["org"], "summary": "Update current Organization's address.", - "operationId": "updateOrgAddress", + "operationId": "updateCurrentOrgAddress", "parameters": [ { "name": "body", @@ -5630,10 +5620,10 @@ "get": { "tags": ["org_invites"], "summary": "Get pending invites.", - "operationId": "getInvites", + "operationId": "getPendingOrgInvites", "responses": { "200": { - "$ref": "#/responses/getInvitesResponse" + "$ref": "#/responses/getPendingOrgInvitesResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -5649,7 +5639,7 @@ "post": { "tags": ["org_invites"], "summary": "Add invite.", - "operationId": "addInvite", + "operationId": "addOrgInvite", "parameters": [ { "name": "body", @@ -5662,7 +5652,7 @@ ], "responses": { "200": { - "$ref": "#/responses/addOrgUser" + "$ref": "#/responses/okResponse" }, "400": { "$ref": "#/responses/badRequestError" @@ -5682,6 +5672,38 @@ } } }, + "/org/invites/{invitation_code}/revoke": { + "delete": { + "tags": ["org_invites"], + "summary": "Revoke invite.", + "operationId": "revokeInvite", + "parameters": [ + { + "type": "string", + "name": "invitation_code", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/okResponse" + }, + "401": { + "$ref": "#/responses/unauthorisedError" + }, + "403": { + "$ref": "#/responses/forbiddenError" + }, + "404": { + "$ref": "#/responses/notFoundError" + }, + "500": { + "$ref": "#/responses/internalServerError" + } + } + } + }, "/org/preferences": { "get": { "tags": ["org_preferences"], @@ -5718,7 +5740,7 @@ ], "responses": { "200": { - "$ref": "#/responses/addOrgUser" + "$ref": "#/responses/okResponse" }, "400": { "$ref": "#/responses/badRequestError" @@ -5750,7 +5772,7 @@ ], "responses": { "200": { - "$ref": "#/responses/addOrgUser" + "$ref": "#/responses/okResponse" }, "400": { "$ref": "#/responses/badRequestError" @@ -5770,12 +5792,12 @@ "/org/users": { "get": { "description": "Returns all org users within the current organization. Accessible to users with org admin role.\nIf you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `org.users:read` with scope `users:*`.", - "tags": ["current_org_details"], + "tags": ["org"], "summary": "Get all users within the current organization.", - "operationId": "getOrgUsers", + "operationId": "getOrgUsersForCurrentOrg", "responses": { "200": { - "$ref": "#/responses/getOrgUsersResponse" + "$ref": "#/responses/getOrgUsersForCurrentOrgResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -5790,9 +5812,9 @@ }, "post": { "description": "Adds a global user to the current organization.\n\nIf you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `org.users:add` with scope `users:*`.", - "tags": ["current_org_details"], + "tags": ["org"], "summary": "Add a new user to the current organization", - "operationId": "addOrgUser", + "operationId": "addOrgUserToCurrentOrg", "parameters": [ { "name": "body", @@ -5822,9 +5844,9 @@ "/org/users/lookup": { "get": { "description": "Returns all org users within the current organization, but with less detailed information.\nAccessible to users with org admin role, admin in any folder or admin of any team.\nMainly used by Grafana UI for providing list of users when adding team members and when editing folder/dashboard permissions.", - "tags": ["current_org_details"], + "tags": ["org"], "summary": "Get all users within the current organization (lookup)", - "operationId": "lookupOrgUsers", + "operationId": "getOrgUsersForCurrentOrgLookup", "parameters": [ { "type": "string", @@ -5840,7 +5862,7 @@ ], "responses": { "200": { - "$ref": "#/responses/lookupOrgUsersResponse" + "$ref": "#/responses/getOrgUsersForCurrentOrgLookupResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -5857,9 +5879,9 @@ "/org/users/{user_id}": { "delete": { "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `org.users:remove` with scope `users:*`.", - "tags": ["current_org_details"], + "tags": ["org"], "summary": "Delete user in current organization", - "operationId": "deleteOrgUser", + "operationId": "removeOrgUserForCurrentOrg", "parameters": [ { "type": "integer", @@ -5889,9 +5911,9 @@ }, "patch": { "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `org.users.role:update` with scope `users:*`.", - "tags": ["current_org_details"], + "tags": ["org"], "summary": "Updates the given user", - "operationId": "updateOrgUser", + "operationId": "updateOrgUserForCurrentOrg", "parameters": [ { "name": "body", @@ -5928,38 +5950,6 @@ } } }, - "/org/{invitation_code}/invites": { - "delete": { - "tags": ["org_invites"], - "summary": "Revoke invite.", - "operationId": "revokeInvite", - "parameters": [ - { - "type": "string", - "name": "invitation_code", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "$ref": "#/responses/okResponse" - }, - "401": { - "$ref": "#/responses/unauthorisedError" - }, - "403": { - "$ref": "#/responses/forbiddenError" - }, - "404": { - "$ref": "#/responses/notFoundError" - }, - "500": { - "$ref": "#/responses/internalServerError" - } - } - } - }, "/orgs": { "get": { "security": [ @@ -5969,7 +5959,7 @@ ], "description": "Search all Organizations", "tags": ["orgs"], - "operationId": "searchOrg", + "operationId": "searchOrgs", "parameters": [ { "type": "integer", @@ -6000,7 +5990,7 @@ ], "responses": { "200": { - "$ref": "#/responses/searchOrgResponse" + "$ref": "#/responses/searchOrgsResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -6070,7 +6060,7 @@ ], "responses": { "200": { - "$ref": "#/responses/getOrgResponse" + "$ref": "#/responses/getOrgByNameResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -6105,7 +6095,7 @@ ], "responses": { "200": { - "$ref": "#/responses/getOrgResponse" + "$ref": "#/responses/getOrgByIDResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -6126,7 +6116,7 @@ ], "tags": ["orgs"], "summary": "Update Organization.", - "operationId": "adminUpdateOrg", + "operationId": "updateOrg", "parameters": [ { "name": "body", @@ -6170,7 +6160,7 @@ ], "tags": ["orgs"], "summary": "Delete Organization.", - "operationId": "adminDeleteOrg", + "operationId": "deleteOrgByID", "parameters": [ { "type": "integer", @@ -6206,7 +6196,7 @@ "put": { "tags": ["orgs"], "summary": "Update Organization's address.", - "operationId": "adminUpdateOrgAddress", + "operationId": "updateOrgAddress", "parameters": [ { "name": "body", @@ -6340,7 +6330,7 @@ "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `org.users:read` with scope `users:*`.", "tags": ["orgs"], "summary": "Get Users in Organization.", - "operationId": "adminGetOrgUsers", + "operationId": "getOrgUsers", "parameters": [ { "type": "integer", @@ -6369,7 +6359,7 @@ "description": "Adds a global user to the current organization.\n\nIf you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `org.users:add` with scope `users:*`.", "tags": ["orgs"], "summary": "Add a new user to the current organization", - "operationId": "adminAddOrgUser", + "operationId": "addOrgUser", "parameters": [ { "name": "body", @@ -6408,7 +6398,7 @@ "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `org.users:remove` with scope `users:*`.", "tags": ["orgs"], "summary": "Delete user in current organization", - "operationId": "adminDeleteOrgUser", + "operationId": "removeOrgUser", "parameters": [ { "type": "integer", @@ -6447,7 +6437,7 @@ "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `org.users.role:update` with scope `users:*`.", "tags": ["orgs"], "summary": "Update Users in Organization.", - "operationId": "adminUpdateOrgUser", + "operationId": "updateOrgUser", "parameters": [ { "name": "body", @@ -6555,7 +6545,7 @@ "/playlists/{uid}": { "get": { "tags": ["playlists"], - "summary": "Get playlist by UID.", + "summary": "Get playlist.", "operationId": "getPlaylist", "parameters": [ { @@ -6623,7 +6613,7 @@ }, "delete": { "tags": ["playlists"], - "summary": "Delete pllaylist.", + "summary": "Delete playlist.", "operationId": "deletePlaylist", "parameters": [ { @@ -6974,8 +6964,8 @@ }, "/recording-rules": { "get": { + "description": "Lists all rules in the database: active or deleted", "tags": ["recording_rules", "enterprise"], - "summary": "Get all recording rules.", "operationId": "listRecordingRules", "responses": { "200": { @@ -6996,8 +6986,8 @@ } }, "put": { + "description": "Update the active status of a rule", "tags": ["recording_rules", "enterprise"], - "summary": "Update a recording rule.", "operationId": "updateRecordingRule", "parameters": [ { @@ -7028,8 +7018,8 @@ } }, "post": { + "description": "Create a recording rule that is then registered and started", "tags": ["recording_rules", "enterprise"], - "summary": "Create a new recording rule.", "operationId": "createRecordingRule", "parameters": [ { @@ -7099,8 +7089,8 @@ }, "/recording-rules/writer": { "get": { + "description": "Return the prometheus remote write target", "tags": ["recording_rules", "enterprise"], - "summary": "Get the write target.", "operationId": "getRecordingRuleWriteTarget", "responses": { "200": { @@ -7121,8 +7111,9 @@ } }, "post": { + "description": "It returns a 422 if there is not an existing prometheus data source configured", "tags": ["recording_rules", "enterprise"], - "summary": "Create a new write target.", + "summary": "Create a remote write target.", "operationId": "createRecordingRuleWriteTarget", "parameters": [ { @@ -7157,7 +7148,7 @@ }, "delete": { "tags": ["recording_rules", "enterprise"], - "summary": "Delete the write target.", + "summary": "Delete the remote write target.", "operationId": "deleteRecordingRuleWriteTarget", "responses": { "200": { @@ -7181,7 +7172,7 @@ "/recording-rules/{recordingRuleID}": { "delete": { "tags": ["recording_rules", "enterprise"], - "summary": "Delete a recording rule.", + "summary": "Delete removes the rule from the registry and stops it.", "operationId": "deleteRecordingRule", "parameters": [ { @@ -7307,7 +7298,7 @@ } } }, - "/reports/render/pdf/{DashboardID}": { + "/reports/render/pdf/{dashboardID}": { "get": { "description": "Please refer to [reports enterprise](#/reports/renderReportPDFs) instead. This will be removed in Grafana 10.", "produces": ["application/pdf"], @@ -7322,6 +7313,43 @@ "name": "DashboardID", "in": "path", "required": true + }, + { + "type": "integer", + "format": "int64", + "name": "dashboardID", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "title", + "in": "query" + }, + { + "type": "string", + "name": "variables", + "in": "query" + }, + { + "type": "string", + "name": "from", + "in": "query" + }, + { + "type": "string", + "name": "to", + "in": "query" + }, + { + "type": "string", + "name": "orientation", + "in": "query" + }, + { + "type": "string", + "name": "layout", + "in": "query" } ], "responses": { @@ -7347,6 +7375,23 @@ "tags": ["reports", "enterprise"], "summary": "Render report for multiple dashboards.", "operationId": "renderReportPDFs", + "parameters": [ + { + "type": "string", + "name": "dashboardID", + "in": "query" + }, + { + "type": "string", + "name": "orientation", + "in": "query" + }, + { + "type": "string", + "name": "layout", + "in": "query" + } + ], "responses": { "200": { "$ref": "#/responses/contentResponse" @@ -7456,7 +7501,7 @@ } } }, - "/reports/{reportID}": { + "/reports/{id}": { "get": { "description": "Available to org admins only and with a valid or expired license\n\nYou need to have a permission with action `reports:read` with scope `reports:id:\u003creport ID\u003e`.", "tags": ["reports", "enterprise"], @@ -7466,7 +7511,7 @@ { "type": "integer", "format": "int64", - "name": "reportID", + "name": "id", "in": "path", "required": true } @@ -7509,7 +7554,7 @@ { "type": "integer", "format": "int64", - "name": "reportID", + "name": "id", "in": "path", "required": true } @@ -7544,7 +7589,7 @@ { "type": "integer", "format": "int64", - "name": "reportID", + "name": "id", "in": "path", "required": true } @@ -7601,7 +7646,7 @@ "produces": ["application/xml;application/samlmetadata+xml"], "tags": ["saml", "enterprise"], "summary": "It exposes the SP (Grafana's) metadata for the IdP's consumption.", - "operationId": "getSAMLMetadata", + "operationId": "getMetadata", "responses": { "200": { "$ref": "#/responses/contentResponse" @@ -7611,6 +7656,7 @@ }, "/saml/slo": { "post": { + "description": "There might be two possible requests:\n1. Logout response (callback) when Grafana initiates single logout and IdP returns response to logout request.\n2. Logout request when another SP initiates single logout and IdP sends logout request to the Grafana,\nor in case of IdP-initiated logout.", "tags": ["saml", "enterprise"], "summary": "It performs Single Logout (SLO) callback.", "operationId": "postSLO", @@ -7756,10 +7802,10 @@ "get": { "description": "List search sorting options", "tags": ["search"], - "operationId": "searchSorting", + "operationId": "listSortOptions", "responses": { "200": { - "$ref": "#/responses/searchSortingResponse" + "$ref": "#/responses/listSortOptionsResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -7805,7 +7851,7 @@ "get": { "description": "Required permissions (See note in the [introduction](https://grafana.com/docs/grafana/latest/developers/http_api/serviceaccount/#service-account-api) for an explanation):\naction: `serviceaccounts:read` scope: `serviceaccounts:*`", "tags": ["service_accounts"], - "summary": "Search service accounts with Paging", + "summary": "Search service accounts with paging", "operationId": "searchOrgServiceAccountsWithPaging", "parameters": [ { @@ -8002,7 +8048,7 @@ "post": { "description": "Required permissions (See note in the [introduction](https://grafana.com/docs/grafana/latest/developers/http_api/serviceaccount/#service-account-api) for an explanation):\naction: `serviceaccounts:write` scope: `serviceaccounts:id:1` (single service account)", "tags": ["service_accounts"], - "summary": "Create service account tokens", + "summary": "CreateNewToken adds a token to a service account", "operationId": "createToken", "parameters": [ { @@ -8049,7 +8095,7 @@ "delete": { "description": "Required permissions (See note in the [introduction](https://grafana.com/docs/grafana/latest/developers/http_api/serviceaccount/#service-account-api) for an explanation):\naction: `serviceaccounts:write` scope: `serviceaccounts:id:1` (single service account)\n\nRequires basic authentication and that the authenticated user is a Grafana Admin.", "tags": ["service_accounts"], - "summary": "Delete service account tokens", + "summary": "DeleteToken deletes service account tokens", "operationId": "deleteToken", "parameters": [ { @@ -8093,10 +8139,10 @@ "get": { "tags": ["snapshots"], "summary": "Get snapshot sharing settings.", - "operationId": "getSnapshotSharingOptions", + "operationId": "getSharingOptions", "responses": { "200": { - "$ref": "#/responses/getSnapshotSharingOptionsResponse" + "$ref": "#/responses/getSharingOptionsResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -8109,7 +8155,7 @@ "description": "Snapshot public mode should be enabled or authentication is required.", "tags": ["snapshots"], "summary": "When creating a snapshot using the API, you have to provide the full dashboard payload including the snapshot data. This endpoint is designed for the Grafana UI.", - "operationId": "createSnapshot", + "operationId": "createDashboardSnapshot", "parameters": [ { "name": "body", @@ -8122,7 +8168,7 @@ ], "responses": { "200": { - "$ref": "#/responses/createSnapshotResponse" + "$ref": "#/responses/createDashboardSnapshotResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -8141,7 +8187,7 @@ "description": "Snapshot public mode should be enabled or authentication is required.", "tags": ["snapshots"], "summary": "Delete Snapshot by deleteKey.", - "operationId": "deleteSnapshotByDeleteKey", + "operationId": "deleteDashboardSnapshotByDeleteKey", "parameters": [ { "type": "string", @@ -8173,7 +8219,7 @@ "get": { "tags": ["snapshots"], "summary": "Get Snapshot by Key.", - "operationId": "getSnapshotByKey", + "operationId": "getDashboardSnapshot", "parameters": [ { "type": "string", @@ -8184,7 +8230,7 @@ ], "responses": { "200": { - "$ref": "#/responses/snapshotResponse" + "$ref": "#/responses/getDashboardSnapshotResponse" }, "404": { "$ref": "#/responses/notFoundError" @@ -8197,7 +8243,7 @@ "delete": { "tags": ["snapshots"], "summary": "Delete Snapshot by Key.", - "operationId": "deleteSnapshotByKey", + "operationId": "deleteDashboardSnapshot", "parameters": [ { "type": "string", @@ -8429,7 +8475,7 @@ "get": { "tags": ["teams"], "summary": "Get Team By ID.", - "operationId": "getTeam", + "operationId": "getTeamByID", "parameters": [ { "type": "string", @@ -8440,7 +8486,7 @@ ], "responses": { "200": { - "$ref": "#/responses/getTeamResponse" + "$ref": "#/responses/getTeamByIDResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -8745,8 +8791,8 @@ }, "/user": { "get": { + "description": "Get (current authenticated user)", "tags": ["signed_in_user"], - "summary": "Get signed in User.", "operationId": "getSignedInUser", "responses": { "200": { @@ -8783,7 +8829,7 @@ ], "responses": { "200": { - "$ref": "#/responses/userResponse" + "$ref": "#/responses/okResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -8802,10 +8848,10 @@ "description": "Return a list of all auth tokens (devices) that the actual user currently have logged in from.", "tags": ["signed_in_user"], "summary": "Auth tokens of the actual User.", - "operationId": "getSignedInUserAuthTokens", + "operationId": "getUserAuthTokens", "responses": { "200": { - "$ref": "#/responses/getAuthTokensResponse" + "$ref": "#/responses/getUserAuthTokensResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -8882,7 +8928,7 @@ "operationId": "getSignedInUserOrgList", "responses": { "200": { - "$ref": "#/responses/getUserOrgListResponse" + "$ref": "#/responses/getSignedInUserOrgListResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -9043,7 +9089,7 @@ "description": "Revokes the given auth token (device) for the actual user. User of issued auth token (device) will no longer be logged in and will be required to authenticate again upon next activity.", "tags": ["signed_in_user"], "summary": "Revoke an auth token of the actual User.", - "operationId": "revokeSignedInAuthToken", + "operationId": "revokeUserAuthToken", "parameters": [ { "name": "body", @@ -9145,7 +9191,7 @@ "operationId": "getSignedInUserTeamList", "responses": { "200": { - "$ref": "#/responses/getUserOrgListResponse" + "$ref": "#/responses/getSignedInUserTeamListResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -9347,7 +9393,7 @@ ], "responses": { "200": { - "$ref": "#/responses/userResponse" + "$ref": "#/responses/okResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -10645,7 +10691,7 @@ } } }, - "CreateCorrelationResponse": { + "CreateCorrelationResponseBody": { "description": "CreateCorrelationResponse is the response struct for CreateCorrelationCommand", "type": "object", "properties": { @@ -11626,7 +11672,7 @@ } } }, - "DeleteCorrelationResponse": { + "DeleteCorrelationResponseBody": { "type": "object", "properties": { "message": { @@ -17651,32 +17697,64 @@ "$ref": "#/definitions/ErrorResponseBody" } }, - "addOrgUser": { + "addPermissionResponse": { "description": "(empty)", "schema": { "type": "object", - "required": ["id", "message"], "properties": { - "id": { - "description": "ID Identifier of the added user.", - "type": "integer", - "format": "int64", - "example": 65 - }, "message": { - "description": "Message Message of the added user.", - "type": "string", - "example": "Data source added" + "type": "string" + }, + "permissionId": { + "type": "integer", + "format": "int64" } } } }, + "adminCreateUserResponse": { + "description": "(empty)", + "schema": { + "$ref": "#/definitions/UserIdDTO" + } + }, + "adminGetSettingsResponse": { + "description": "(empty)", + "schema": { + "$ref": "#/definitions/SettingsBag" + } + }, + "adminGetStatsResponse": { + "description": "(empty)", + "schema": { + "$ref": "#/definitions/AdminStats" + } + }, + "adminGetUserAuthTokensResponse": { + "description": "(empty)", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/UserToken" + } + } + }, "badRequestError": { "description": "BadRequestError is returned when the request is invalid and it cannot be processed.", "schema": { "$ref": "#/definitions/ErrorResponseBody" } }, + "calculateDashboardDiffResponse": { + "description": "(empty)", + "schema": { + "type": "array", + "items": { + "type": "integer", + "format": "uint8" + } + } + }, "conflictError": { "description": "ConflictError", "schema": { @@ -17693,29 +17771,37 @@ } } }, - "createAnnotationResponse": { - "description": "(empty)", - "schema": { - "type": "object", - "required": ["id", "message"], - "properties": { - "id": { - "description": "ID Identifier of the created annotation.", - "type": "integer", - "format": "int64", - "example": 65 - }, - "message": { - "description": "Message Message of the created annotation.", - "type": "string" - } - } - } - }, "createCorrelationResponse": { "description": "(empty)", "schema": { - "$ref": "#/definitions/CreateCorrelationResponse" + "$ref": "#/definitions/CreateCorrelationResponseBody" + } + }, + "createDashboardSnapshotResponse": { + "description": "(empty)", + "schema": { + "type": "object", + "properties": { + "deleteKey": { + "description": "Unique key used to delete the snapshot. It is different from the key so that only the creator can delete the snapshot.", + "type": "string" + }, + "deleteUrl": { + "type": "string" + }, + "id": { + "description": "Snapshot id", + "type": "integer", + "format": "int64" + }, + "key": { + "description": "Unique key", + "type": "string" + }, + "url": { + "type": "string" + } + } } }, "createOrUpdateDatasourceResponse": { @@ -17787,39 +17873,18 @@ } } }, + "createRoleResponse": { + "description": "(empty)", + "schema": { + "$ref": "#/definitions/RoleDTO" + } + }, "createServiceAccountResponse": { "description": "(empty)", "schema": { "$ref": "#/definitions/ServiceAccountDTO" } }, - "createSnapshotResponse": { - "description": "(empty)", - "schema": { - "type": "object", - "properties": { - "deleteKey": { - "description": "Unique key used to delete the snapshot. It is different from the key so that only the creator can delete the snapshot.", - "type": "string" - }, - "deleteUrl": { - "type": "string" - }, - "id": { - "description": "Snapshot id", - "type": "integer", - "format": "int64" - }, - "key": { - "description": "Unique key", - "type": "string" - }, - "url": { - "type": "string" - } - } - } - }, "createTeamResponse": { "description": "(empty)", "schema": { @@ -17841,22 +17906,6 @@ "$ref": "#/definitions/NewApiKeyResult" } }, - "createUserResponse": { - "description": "(empty)", - "schema": { - "$ref": "#/definitions/UserIdDTO" - } - }, - "dashboardDiffResponse": { - "description": "Calculate dashboard diff response.", - "schema": { - "type": "array", - "items": { - "type": "integer", - "format": "uint8" - } - } - }, "dashboardResponse": { "description": "(empty)", "schema": { @@ -17878,15 +17927,6 @@ } } }, - "dashboardsTagsResponse": { - "description": "(empty)", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/DashboardTagCloudItem" - } - } - }, "deleteAlertNotificationChannelResponse": { "description": "(empty)", "schema": { @@ -17909,7 +17949,7 @@ "deleteCorrelationResponse": { "description": "(empty)", "schema": { - "$ref": "#/definitions/DeleteCorrelationResponse" + "$ref": "#/definitions/DeleteCorrelationResponseBody" } }, "deleteDashboardResponse": { @@ -17937,7 +17977,7 @@ } } }, - "deleteDatasourceByNameResponse": { + "deleteDataSourceByNameResponse": { "description": "(empty)", "schema": { "type": "object", @@ -18030,6 +18070,15 @@ } } }, + "getAlertNotificationLookupResponse": { + "description": "(empty)", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/AlertNotificationLookup" + } + } + }, "getAlertResponse": { "description": "(empty)", "schema": { @@ -18045,6 +18094,12 @@ } } }, + "getAllPermissionseResponse": { + "description": "(empty)", + "schema": { + "$ref": "#/definitions/DataSourcePermissionsDTO" + } + }, "getAllRolesResponse": { "description": "(empty)", "schema": { @@ -18054,7 +18109,7 @@ } } }, - "getAnnotationResponse": { + "getAnnotationByIDResponse": { "description": "(empty)", "schema": { "$ref": "#/definitions/ItemDTO" @@ -18075,13 +18130,10 @@ } } }, - "getAuthTokensResponse": { + "getCurrentOrgResponse": { "description": "(empty)", "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/UserToken" - } + "$ref": "#/definitions/OrgDetailsDTO" } }, "getCustomPermissionsReportResponse": { @@ -18093,7 +18145,7 @@ } } }, - "getDashboardPermissionsResponse": { + "getDashboardPermissionsListResponse": { "description": "(empty)", "schema": { "type": "array", @@ -18102,6 +18154,9 @@ } } }, + "getDashboardSnapshotResponse": { + "description": "(empty)" + }, "getDashboardStatesResponse": { "description": "(empty)", "schema": { @@ -18111,7 +18166,16 @@ } } }, - "getDatasourceIDresponse": { + "getDashboardsTagsResponse": { + "description": "(empty)", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/DashboardTagCloudItem" + } + } + }, + "getDataSourceIDResponse": { "description": "(empty)", "schema": { "type": "object", @@ -18126,18 +18190,27 @@ } } }, - "getDatasourceResponse": { + "getDataSourceResponse": { "description": "(empty)", "schema": { "$ref": "#/definitions/DataSource" } }, - "getDatasourcesResponse": { + "getDataSourcesResponse": { "description": "(empty)", "schema": { "$ref": "#/definitions/DataSourceList" } }, + "getFolderPermissionListResponse": { + "description": "(empty)", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/DashboardACLInfoDTO" + } + } + }, "getFoldersResponse": { "description": "(empty)", "schema": { @@ -18148,26 +18221,11 @@ } }, "getHomeDashboardResponse": { - "description": "Home dashboard response.", + "description": "(empty)", "schema": { "$ref": "#/definitions/GetHomeDashboardResponse" } }, - "getInvitesResponse": { - "description": "(empty)", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/TempUserDTO" - } - } - }, - "getLDAPSyncStatusResponse": { - "description": "(empty)", - "schema": { - "$ref": "#/definitions/ActiveSyncStatusDTO" - } - }, "getLibraryElementConnectionsResponse": { "description": "(empty)", "schema": { @@ -18186,21 +18244,42 @@ "$ref": "#/definitions/LibraryElementSearchResponse" } }, - "getLicenseStatusResponse": { - "description": "(empty)" - }, "getLicenseTokenResponse": { "description": "(empty)", "schema": { "$ref": "#/definitions/Token" } }, - "getOrgResponse": { + "getOrgByIDResponse": { "description": "(empty)", "schema": { "$ref": "#/definitions/OrgDetailsDTO" } }, + "getOrgByNameResponse": { + "description": "(empty)", + "schema": { + "$ref": "#/definitions/OrgDetailsDTO" + } + }, + "getOrgUsersForCurrentOrgLookupResponse": { + "description": "(empty)", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/UserLookupDTO" + } + } + }, + "getOrgUsersForCurrentOrgResponse": { + "description": "(empty)", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/OrgUserDTO" + } + } + }, "getOrgUsersResponse": { "description": "(empty)", "schema": { @@ -18210,10 +18289,13 @@ } } }, - "getPermissionseResponse": { + "getPendingOrgInvitesResponse": { "description": "(empty)", "schema": { - "$ref": "#/definitions/DataSourcePermissionsDTO" + "type": "array", + "items": { + "$ref": "#/definitions/TempUserDTO" + } } }, "getPlaylistDashboardsResponse": { @@ -18303,13 +18385,7 @@ "$ref": "#/definitions/RoleDTO" } }, - "getSettingsResponse": { - "description": "(empty)", - "schema": { - "$ref": "#/definitions/SettingsBag" - } - }, - "getSnapshotSharingOptionsResponse": { + "getSharingOptionsResponse": { "description": "(empty)", "schema": { "type": "object", @@ -18326,19 +18402,37 @@ } } }, - "getSnapshotsResponse": { + "getSignedInUserOrgListResponse": { "description": "(empty)", "schema": { "type": "array", "items": { - "$ref": "#/definitions/DashboardSnapshotDTO" + "$ref": "#/definitions/UserOrgDTO" } } }, - "getStatsResponse": { + "getSignedInUserTeamListResponse": { "description": "(empty)", "schema": { - "$ref": "#/definitions/AdminStats" + "type": "array", + "items": { + "$ref": "#/definitions/TeamDTO" + } + } + }, + "getStatusResponse": { + "description": "(empty)" + }, + "getSyncStatusResponse": { + "description": "(empty)", + "schema": { + "$ref": "#/definitions/ActiveSyncStatusDTO" + } + }, + "getTeamByIDResponse": { + "description": "(empty)", + "schema": { + "$ref": "#/definitions/TeamDTO" } }, "getTeamGroupsApiResponse": { @@ -18359,10 +18453,13 @@ } } }, - "getTeamResponse": { + "getUserAuthTokensResponse": { "description": "(empty)", "schema": { - "$ref": "#/definitions/TeamDTO" + "type": "array", + "items": { + "$ref": "#/definitions/UserToken" + } } }, "getUserOrgListResponse": { @@ -18431,30 +18528,41 @@ } } }, + "listRolesResponse": { + "description": "(empty)", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/RoleDTO" + } + } + }, + "listSortOptionsResponse": { + "description": "(empty)", + "schema": { + "type": "object", + "properties": { + "description": { + "type": "string" + }, + "displayName": { + "type": "string" + }, + "meta": { + "type": "string" + }, + "name": { + "type": "string" + } + } + } + }, "listTokensResponse": { "description": "(empty)", "schema": { "$ref": "#/definitions/TokenDTO" } }, - "lookupAlertNotificationChannelsResponse": { - "description": "(empty)", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/AlertNotificationLookup" - } - } - }, - "lookupOrgUsersResponse": { - "description": "(empty)", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/UserLookupDTO" - } - } - }, "notFoundError": { "description": "NotFoundError is returned when the requested resource was not found.", "schema": { @@ -18514,8 +18622,27 @@ "$ref": "#/definitions/NewApiKeyResult" } }, + "postAnnotationResponse": { + "description": "(empty)", + "schema": { + "type": "object", + "required": ["id", "message"], + "properties": { + "id": { + "description": "ID Identifier of the created annotation.", + "type": "integer", + "format": "int64", + "example": 65 + }, + "message": { + "description": "Message Message of the created annotation.", + "type": "string" + } + } + } + }, "postDashboardResponse": { - "description": "Create/update dashboard response.", + "description": "(empty)", "schema": { "type": "object", "required": ["status", "title", "version", "id", "uid", "url"], @@ -18563,7 +18690,7 @@ "$ref": "#/definitions/ErrorResponseBody" } }, - "queryDataResponse": { + "queryMetricsWithExpressionsRespons": { "description": "(empty)", "schema": { "$ref": "#/definitions/QueryDataResponse" @@ -18593,12 +18720,12 @@ "$ref": "#/definitions/ServiceAccountDTO" } }, - "searchOrgResponse": { + "searchDashboardSnapshotsResponse": { "description": "(empty)", "schema": { "type": "array", "items": { - "$ref": "#/definitions/OrgDTO" + "$ref": "#/definitions/DashboardSnapshotDTO" } } }, @@ -18608,6 +18735,15 @@ "$ref": "#/definitions/SearchServiceAccountsResult" } }, + "searchOrgsResponse": { + "description": "(empty)", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/OrgDTO" + } + } + }, "searchPlaylistsResponse": { "description": "(empty)", "schema": { @@ -18620,26 +18756,6 @@ "$ref": "#/definitions/HitList" } }, - "searchSortingResponse": { - "description": "(empty)", - "schema": { - "type": "object", - "properties": { - "description": { - "type": "string" - }, - "displayName": { - "type": "string" - }, - "meta": { - "type": "string" - }, - "name": { - "type": "string" - } - } - } - }, "searchTeamsResponse": { "description": "(empty)", "schema": { @@ -18652,9 +18768,6 @@ "$ref": "#/definitions/SearchUserQueryResult" } }, - "snapshotResponse": { - "description": "(empty)" - }, "testAlertResponse": { "description": "(empty)", "schema": { @@ -18662,7 +18775,7 @@ } }, "trimDashboardResponse": { - "description": "Trimmed dashboard response.", + "description": "(empty)", "schema": { "$ref": "#/definitions/TrimDashboardFullWithMeta" } @@ -18774,7 +18887,7 @@ }, { "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled, for some endpoints you would need to have relevant permissions. Refer to specific resources to understand what permissions are required.", - "name": "current_org_details" + "name": "org" }, { "description": "This API can be used to create/update/delete Teams and to add/remove users to Teams. All actions require that the user has the Admin role for the organization.", diff --git a/public/api-spec.json b/public/api-spec.json index 28566e177ef..5c01a5b4bbd 100644 --- a/public/api-spec.json +++ b/public/api-spec.json @@ -118,7 +118,7 @@ "description": "Gets all existing roles. The response contains all global and organization local roles, for the organization which user is signed in.\n\nYou need to have a permission with action `roles:list` and scope `roles:*`.", "tags": ["access_control", "enterprise"], "summary": "Get all roles.", - "operationId": "getAllRoles", + "operationId": "listRoles", "parameters": [ { "type": "boolean", @@ -128,7 +128,7 @@ ], "responses": { "200": { - "$ref": "#/responses/getAllRolesResponse" + "$ref": "#/responses/listRolesResponse" }, "403": { "$ref": "#/responses/forbiddenError" @@ -142,7 +142,7 @@ "description": "Creates a new custom role and maps given permissions to that role. Note that roles with the same prefix as Fixed Roles can’t be created.\n\nYou need to have a permission with action `roles:write` and scope `permissions:type:delegate`. `permissions:type:delegate`` scope ensures that users can only create custom roles with the same, or a subset of permissions which the user has.\nFor example, if a user does not have required permissions for creating users, they won’t be able to create a custom role which allows to do that. This is done to prevent escalation of privileges.", "tags": ["access_control", "enterprise"], "summary": "Create a new custom role.", - "operationId": "createRoleWithPermissions", + "operationId": "createRole", "parameters": [ { "name": "body", @@ -154,8 +154,8 @@ } ], "responses": { - "200": { - "$ref": "#/responses/getRoleResponse" + "201": { + "$ref": "#/responses/createRoleResponse" }, "400": { "$ref": "#/responses/badRequestError" @@ -596,11 +596,11 @@ "get": { "description": "You need to have a permission with action `ldap.status:read`.", "tags": ["ldap_debug"], - "summary": "Available to grafana admins.", - "operationId": "getLDAPSyncStatus", + "summary": "Returns the current state of the LDAP background sync integration", + "operationId": "getSyncStatus", "responses": { "200": { - "$ref": "#/responses/getLDAPSyncStatusResponse" + "$ref": "#/responses/getSyncStatusResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -624,7 +624,7 @@ "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `ldap.config:reload`.", "tags": ["admin_ldap"], "summary": "Reloads the LDAP configuration.", - "operationId": "reloadLDAP", + "operationId": "reloadLDAPCfg", "responses": { "200": { "$ref": "#/responses/okResponse" @@ -678,7 +678,7 @@ "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `ldap.user:sync`.", "tags": ["admin_ldap"], "summary": "Enables a single Grafana user to be synchronized against LDAP.", - "operationId": "syncLDAPUser", + "operationId": "postSyncUserWithLDAP", "parameters": [ { "type": "integer", @@ -714,7 +714,7 @@ "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `ldap.user:read`.", "tags": ["admin_ldap"], "summary": "Finds an user based on a username in LDAP. This helps illustrate how would the particular user be mapped in Grafana when synced.", - "operationId": "getLDAPUser", + "operationId": "getUserFromLDAP", "parameters": [ { "type": "string", @@ -793,33 +793,6 @@ } } }, - "/admin/provisioning/accesscontrol/reload": { - "post": { - "security": [ - { - "basic": [] - } - ], - "description": "Reloads the provisioning config files for access control again. It won’t return until the new provisioned entities are already stored in the database. In case of dashboards, it will stop polling for changes in dashboard files and then restart it with new configurations after returning.\nIf you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `provisioning:reload` and scope `provisioners:accesscontrol`.", - "tags": ["admin_provisioning"], - "summary": "Reload access control provisioning configurations.", - "operationId": "reloadProvisionedAccessControl", - "responses": { - "200": { - "$ref": "#/responses/okResponse" - }, - "401": { - "$ref": "#/responses/unauthorisedError" - }, - "403": { - "$ref": "#/responses/forbiddenError" - }, - "500": { - "$ref": "#/responses/internalServerError" - } - } - } - }, "/admin/provisioning/dashboards/reload": { "post": { "security": [ @@ -830,7 +803,7 @@ "description": "Reloads the provisioning config files for dashboards again. It won’t return until the new provisioned entities are already stored in the database. In case of dashboards, it will stop polling for changes in dashboard files and then restart it with new configurations after returning.\nIf you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `provisioning:reload` and scope `provisioners:dashboards`.", "tags": ["admin_provisioning"], "summary": "Reload dashboard provisioning configurations.", - "operationId": "reloadProvisionedDashboards", + "operationId": "adminProvisioningReloadDashboards", "responses": { "200": { "$ref": "#/responses/okResponse" @@ -857,7 +830,7 @@ "description": "Reloads the provisioning config files for datasources again. It won’t return until the new provisioned entities are already stored in the database. In case of dashboards, it will stop polling for changes in dashboard files and then restart it with new configurations after returning.\nIf you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `provisioning:reload` and scope `provisioners:datasources`.", "tags": ["admin_provisioning"], "summary": "Reload datasource provisioning configurations.", - "operationId": "reloadProvisionedDatasources", + "operationId": "adminProvisioningReloadDatasources", "responses": { "200": { "$ref": "#/responses/okResponse" @@ -884,7 +857,7 @@ "description": "Reloads the provisioning config files for legacy alert notifiers again. It won’t return until the new provisioned entities are already stored in the database. In case of dashboards, it will stop polling for changes in dashboard files and then restart it with new configurations after returning.\nIf you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `provisioning:reload` and scope `provisioners:notifications`.", "tags": ["admin_provisioning"], "summary": "Reload legacy alert notifier provisioning configurations.", - "operationId": "reloadProvisionedAlertNotifiers", + "operationId": "adminProvisioningReloadNotifications", "responses": { "200": { "$ref": "#/responses/okResponse" @@ -911,7 +884,7 @@ "description": "Reloads the provisioning config files for plugins again. It won’t return until the new provisioned entities are already stored in the database. In case of dashboards, it will stop polling for changes in dashboard files and then restart it with new configurations after returning.\nIf you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `provisioning:reload` and scope `provisioners:plugin`.", "tags": ["admin_provisioning"], "summary": "Reload plugin provisioning configurations.", - "operationId": "reloadProvisionedPlugins", + "operationId": "adminProvisioningReloadPlugins", "responses": { "200": { "$ref": "#/responses/okResponse" @@ -938,10 +911,10 @@ "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `settings:read` and scopes: `settings:*`, `settings:auth.saml:` and `settings:auth.saml:enabled` (property level).", "tags": ["admin"], "summary": "Fetch settings.", - "operationId": "getSettings", + "operationId": "adminGetSettings", "responses": { "200": { - "$ref": "#/responses/getSettingsResponse" + "$ref": "#/responses/adminGetSettingsResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -957,10 +930,10 @@ "description": "Only works with Basic Authentication (username and password). See introduction for an explanation.\nIf you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `server:stats:read`.", "tags": ["admin"], "summary": "Fetch Grafana Stats.", - "operationId": "getStats", + "operationId": "adminGetStats", "responses": { "200": { - "$ref": "#/responses/getStatsResponse" + "$ref": "#/responses/adminGetStatsResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -984,7 +957,7 @@ "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `users:create`.\nNote that OrgId is an optional parameter that can be used to assign a new user to a different organization when `auto_assign_org` is set to `true`.", "tags": ["admin_users"], "summary": "Create new user.", - "operationId": "createUser", + "operationId": "adminCreateUser", "parameters": [ { "name": "body", @@ -997,7 +970,7 @@ ], "responses": { "200": { - "$ref": "#/responses/createUserResponse" + "$ref": "#/responses/adminCreateUserResponse" }, "400": { "$ref": "#/responses/badRequestError" @@ -1027,7 +1000,7 @@ "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `users:delete` and scope `global.users:*`.", "tags": ["admin_users"], "summary": "Delete global User.", - "operationId": "deleteUser", + "operationId": "adminDeleteUser", "parameters": [ { "type": "integer", @@ -1066,7 +1039,7 @@ "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `users.authtoken:list` and scope `global.users:*`.", "tags": ["admin_users"], "summary": "Return a list of all auth tokens (devices) that the user currently have logged in from.", - "operationId": "getAuthTokens", + "operationId": "adminGetUserAuthTokens", "parameters": [ { "type": "integer", @@ -1078,7 +1051,7 @@ ], "responses": { "200": { - "$ref": "#/responses/getAuthTokensResponse" + "$ref": "#/responses/adminGetUserAuthTokensResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -1102,7 +1075,7 @@ "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `users:disable` and scope `global.users:1` (userIDScope).", "tags": ["admin_users"], "summary": "Disable user.", - "operationId": "disableUser", + "operationId": "adminDisableUser", "parameters": [ { "type": "integer", @@ -1141,7 +1114,7 @@ "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `users:enable` and scope `global.users:1` (userIDScope).", "tags": ["admin_users"], "summary": "Enable user.", - "operationId": "enableUser", + "operationId": "adminEnableUser", "parameters": [ { "type": "integer", @@ -1180,7 +1153,7 @@ "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `users.logout` and scope `global.users:*`.", "tags": ["admin_users"], "summary": "Logout user revokes all auth tokens (devices) for the user. User of issued auth tokens (devices) will no longer be logged in and will be required to authenticate again upon next activity.", - "operationId": "logoutUser", + "operationId": "adminLogoutUser", "parameters": [ { "type": "integer", @@ -1222,7 +1195,7 @@ "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `users.password:update` and scope `global.users:*`.", "tags": ["admin_users"], "summary": "Set password for user.", - "operationId": "setPassword", + "operationId": "adminUpdateUserPassword", "parameters": [ { "name": "body", @@ -1264,7 +1237,7 @@ "description": "Only works with Basic Authentication (username and password). See introduction for an explanation.\nIf you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `users.permissions:update` and scope `global.users:*`.", "tags": ["admin_users"], "summary": "Set permissions for user.", - "operationId": "setPermissions", + "operationId": "adminUpdateUserPermissions", "parameters": [ { "name": "body", @@ -1352,6 +1325,14 @@ "summary": "Update user quota.", "operationId": "updateUserQuota", "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/UpdateUserQuotaCmd" + } + }, { "type": "string", "name": "quota_target", @@ -1364,14 +1345,6 @@ "name": "user_id", "in": "path", "required": true - }, - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/UpdateUserQuotaCmd" - } } ], "responses": { @@ -1403,7 +1376,7 @@ "description": "Revokes the given auth token (device) for the user. User of issued auth token (device) will no longer be logged in and will be required to authenticate again upon next activity.\nIf you are running Grafana Enterprise and have Fine-grained access control enabled, you need to have a permission with action `users.authtoken:update` and scope `global.users:*`.", "tags": ["admin_users"], "summary": "Revoke auth token for user.", - "operationId": "revokeAuthToken", + "operationId": "adminRevokeUserAuthToken", "parameters": [ { "name": "body", @@ -1503,10 +1476,10 @@ "description": "Returns all notification channels, but with less detailed information. Accessible by any authenticated user and is mainly used by providing alert notification channels in Grafana UI when configuring alert rule.", "tags": ["legacy_alerts_notification_channels"], "summary": "Get all notification channels (lookup)", - "operationId": "lookupAlertNotificationChannels", + "operationId": "getAlertNotificationLookup", "responses": { "200": { - "$ref": "#/responses/lookupAlertNotificationChannelsResponse" + "$ref": "#/responses/getAlertNotificationLookupResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -2078,7 +2051,7 @@ "description": "Creates an annotation in the Grafana database. The dashboardId and panelId fields are optional. If they are not specified then an organization annotation is created and can be queried in any dashboard that adds the Grafana annotations data source. When creating a region annotation include the timeEnd property.\nThe format for `time` and `timeEnd` should be epoch numbers in millisecond resolution.\nThe response for this HTTP request is slightly different in versions prior to v6.4. In prior versions you would also get an endId if you where creating a region. But in 6.4 regions are represented using a single event with time and timeEnd properties.", "tags": ["annotations"], "summary": "Create Annotation.", - "operationId": "createAnnotation", + "operationId": "postAnnotation", "parameters": [ { "name": "body", @@ -2091,7 +2064,7 @@ ], "responses": { "200": { - "$ref": "#/responses/createAnnotationResponse" + "$ref": "#/responses/postAnnotationResponse" }, "400": { "$ref": "#/responses/badRequestError" @@ -2113,7 +2086,7 @@ "description": "Creates an annotation by using Graphite-compatible event format. The `when` and `data` fields are optional. If `when` is not specified then the current time will be used as annotation’s timestamp. The `tags` field can also be in prior to Graphite `0.10.0` format (string with multiple tags being separated by a space).", "tags": ["annotations"], "summary": "Create Annotation in Graphite format.", - "operationId": "createGraphiteAnnotation", + "operationId": "postGraphiteAnnotation", "parameters": [ { "name": "body", @@ -2126,7 +2099,7 @@ ], "responses": { "200": { - "$ref": "#/responses/createAnnotationResponse" + "$ref": "#/responses/postAnnotationResponse" }, "400": { "$ref": "#/responses/badRequestError" @@ -2209,7 +2182,7 @@ "get": { "tags": ["annotations"], "summary": "Get Annotation by Id.", - "operationId": "getAnnotation", + "operationId": "getAnnotationByID", "parameters": [ { "type": "string", @@ -2220,7 +2193,7 @@ ], "responses": { "200": { - "$ref": "#/responses/getAnnotationResponse" + "$ref": "#/responses/getAnnotationByIDResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -2273,7 +2246,7 @@ "description": "Deletes the annotation that matches the specified ID.", "tags": ["annotations"], "summary": "Delete Annotation By ID.", - "operationId": "deleteAnnotation", + "operationId": "deleteAnnotationByID", "parameters": [ { "type": "string", @@ -2444,7 +2417,7 @@ "get": { "tags": ["snapshots"], "summary": "List snapshots.", - "operationId": "getSnapshots", + "operationId": "searchDashboardSnapshots", "parameters": [ { "type": "string", @@ -2463,7 +2436,7 @@ ], "responses": { "200": { - "$ref": "#/responses/getSnapshotsResponse" + "$ref": "#/responses/searchDashboardSnapshotsResponse" }, "500": { "$ref": "#/responses/internalServerError" @@ -2476,7 +2449,7 @@ "produces": ["application/json", "text/html"], "tags": ["dashboards"], "summary": "Perform diff on two dashboards.", - "operationId": "calcDashboardDiff", + "operationId": "calculateDashboardDiff", "parameters": [ { "name": "Body", @@ -2502,7 +2475,7 @@ ], "responses": { "200": { - "$ref": "#/responses/dashboardDiffResponse" + "$ref": "#/responses/calculateDashboardDiffResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -2580,10 +2553,10 @@ }, "/dashboards/id/{DashboardID}/permissions": { "get": { - "description": "Please refer to [updated API](#/dashboard_permissions/getDashboardPermissionsWithUid) instead", + "description": "Please refer to [updated API](#/dashboard_permissions/getDashboardPermissionsListByUID) instead", "tags": ["dashboard_permissions"], "summary": "Gets all existing permissions for the given dashboard.", - "operationId": "getDashboardPermissions", + "operationId": "getDashboardPermissionsListByID", "deprecated": true, "parameters": [ { @@ -2596,7 +2569,7 @@ ], "responses": { "200": { - "$ref": "#/responses/getDashboardPermissionsResponse" + "$ref": "#/responses/getDashboardPermissionsListResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -2613,10 +2586,10 @@ } }, "post": { - "description": "Please refer to [updated API](#/dashboard_permissions/postDashboardPermissionsWithUid) instead\n\nThis operation will remove existing permissions if they’re not included in the request.", + "description": "Please refer to [updated API](#/dashboard_permissions/updateDashboardPermissionsByUID) instead\n\nThis operation will remove existing permissions if they’re not included in the request.", "tags": ["dashboard_permissions"], "summary": "Updates permissions for a dashboard.", - "operationId": "postDashboardPermissions", + "operationId": "updateDashboardPermissionsByID", "deprecated": true, "parameters": [ { @@ -2662,16 +2635,9 @@ "description": "Please refer to [updated API](#/dashboard_versions/restoreDashboardVersionByUID) instead", "tags": ["dashboard_versions"], "summary": "Restore a dashboard to a given dashboard version.", - "operationId": "restoreDashboardVersion", + "operationId": "restoreDashboardVersionByID", "deprecated": true, "parameters": [ - { - "type": "integer", - "format": "int64", - "name": "DashboardID", - "in": "path", - "required": true - }, { "name": "Body", "in": "body", @@ -2679,6 +2645,13 @@ "schema": { "$ref": "#/definitions/RestoreDashboardVersionCommand" } + }, + { + "type": "integer", + "format": "int64", + "name": "DashboardID", + "in": "path", + "required": true } ], "responses": { @@ -2705,7 +2678,7 @@ "description": "Please refer to [updated API](#/dashboard_versions/getDashboardVersionsByUID) instead", "tags": ["dashboard_versions"], "summary": "Gets all existing versions for the dashboard.", - "operationId": "getDashboardVersions", + "operationId": "getDashboardVersionsByID", "deprecated": true, "parameters": [ { @@ -2714,22 +2687,6 @@ "name": "DashboardID", "in": "path", "required": true - }, - { - "type": "integer", - "format": "int64", - "default": 0, - "description": "Maximum number of results to return", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "format": "int64", - "default": 0, - "description": "Version to start from when returning queries", - "name": "start", - "in": "query" } ], "responses": { @@ -2756,7 +2713,7 @@ "description": "Please refer to [updated API](#/dashboard_versions/getDashboardVersionByUID) instead", "tags": ["dashboard_versions"], "summary": "Get a specific dashboard version.", - "operationId": "getDashboardVersion", + "operationId": "getDashboardVersionByID", "deprecated": true, "parameters": [ { @@ -2837,7 +2794,7 @@ "operationId": "getDashboardTags", "responses": { "200": { - "$ref": "#/responses/dashboardsTagsResponse" + "$ref": "#/responses/getDashboardsTagsResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -2944,7 +2901,7 @@ "get": { "tags": ["dashboard_permissions"], "summary": "Gets all existing permissions for the given dashboard.", - "operationId": "getDashboardPermissionsWithUid", + "operationId": "getDashboardPermissionsListByUID", "parameters": [ { "type": "string", @@ -2955,7 +2912,7 @@ ], "responses": { "200": { - "$ref": "#/responses/getDashboardPermissionsResponse" + "$ref": "#/responses/getDashboardPermissionsListResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -2975,7 +2932,7 @@ "description": "This operation will remove existing permissions if they’re not included in the request.", "tags": ["dashboard_permissions"], "summary": "Updates permissions for a dashboard.", - "operationId": "postDashboardPermissionsWithUid", + "operationId": "updateDashboardPermissionsByUID", "parameters": [ { "name": "Body", @@ -3020,12 +2977,6 @@ "summary": "Restore a dashboard to a given dashboard version using UID.", "operationId": "restoreDashboardVersionByUID", "parameters": [ - { - "type": "string", - "name": "uid", - "in": "path", - "required": true - }, { "name": "Body", "in": "body", @@ -3033,6 +2984,12 @@ "schema": { "$ref": "#/definitions/RestoreDashboardVersionCommand" } + }, + { + "type": "string", + "name": "uid", + "in": "path", + "required": true } ], "responses": { @@ -3109,15 +3066,15 @@ "operationId": "getDashboardVersionByUID", "parameters": [ { - "type": "string", - "name": "uid", + "type": "integer", + "format": "int64", + "name": "DashboardVersionID", "in": "path", "required": true }, { - "type": "integer", - "format": "int64", - "name": "DashboardVersionID", + "type": "string", + "name": "uid", "in": "path", "required": true } @@ -3146,10 +3103,10 @@ "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `datasources:read` and scope: `datasources:*`.", "tags": ["datasources"], "summary": "Get all data sources.", - "operationId": "getDatasources", + "operationId": "getDataSources", "responses": { "200": { - "$ref": "#/responses/getDatasourcesResponse" + "$ref": "#/responses/getDataSourcesResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -3166,7 +3123,7 @@ "description": "By defining `password` and `basicAuthPassword` under secureJsonData property\nGrafana encrypts them securely as an encrypted blob in the database.\nThe response then lists the encrypted fields under secureJsonFields.\n\nIf you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `datasources:create`", "tags": ["datasources"], "summary": "Create a data source.", - "operationId": "addDatasource", + "operationId": "addDataSource", "parameters": [ { "name": "Body", @@ -3201,7 +3158,7 @@ "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `datasources:read` and scopes: `datasources:*`, `datasources:name:*` and `datasources:name:test_datasource` (single data source).", "tags": ["datasources"], "summary": "Get data source Id by Name.", - "operationId": "getDatasourceIdByName", + "operationId": "getDataSourceIdByName", "parameters": [ { "type": "string", @@ -3212,7 +3169,7 @@ ], "responses": { "200": { - "$ref": "#/responses/getDatasourceIDresponse" + "$ref": "#/responses/getDataSourceIDResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -3234,7 +3191,7 @@ "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `datasources:read` and scopes: `datasources:*`, `datasources:name:*` and `datasources:name:test_datasource` (single data source).", "tags": ["datasources"], "summary": "Get a single data source by Name.", - "operationId": "getDatasourceByName", + "operationId": "getDataSourceByName", "parameters": [ { "type": "string", @@ -3245,7 +3202,7 @@ ], "responses": { "200": { - "$ref": "#/responses/getDatasourceResponse" + "$ref": "#/responses/getDataSourceResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -3262,7 +3219,7 @@ "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `datasources:delete` and scopes: `datasources:*`, `datasources:name:*` and `datasources:name:test_datasource` (single data source).", "tags": ["datasources"], "summary": "Delete an existing data source by name.", - "operationId": "deleteDatasourceByName", + "operationId": "deleteDataSourceByName", "parameters": [ { "type": "string", @@ -3273,7 +3230,7 @@ ], "responses": { "200": { - "$ref": "#/responses/deleteDatasourceByNameResponse" + "$ref": "#/responses/deleteDataSourceByNameResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -3607,7 +3564,7 @@ "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `datasources:read` and scopes: `datasources:*`, `datasources:uid:*` and `datasources:uid:kLtEtcRGk` (single data source).", "tags": ["datasources"], "summary": "Get a single data source by UID.", - "operationId": "getDatasourceByUID", + "operationId": "getDataSourceByUID", "parameters": [ { "type": "string", @@ -3618,7 +3575,7 @@ ], "responses": { "200": { - "$ref": "#/responses/getDatasourceResponse" + "$ref": "#/responses/getDataSourceResponse" }, "400": { "$ref": "#/responses/badRequestError" @@ -3641,7 +3598,7 @@ "description": "Similar to creating a data source, `password` and `basicAuthPassword` should be defined under\nsecureJsonData in order to be stored securely as an encrypted blob in the database. Then, the\nencrypted fields are listed under secureJsonFields section in the response.\n\nIf you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `datasources:write` and scopes: `datasources:*`, `datasources:uid:*` and `datasources:uid:1` (single data source).", "tags": ["datasources"], "summary": "Update an existing data source.", - "operationId": "updateDatasourceByUID", + "operationId": "updateDataSourceByUID", "parameters": [ { "name": "Body", @@ -3677,7 +3634,7 @@ "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `datasources:delete` and scopes: `datasources:*`, `datasources:uid:*` and `datasources:uid:kLtEtcRGk` (single data source).", "tags": ["datasources"], "summary": "Delete an existing data source by UID.", - "operationId": "deleteDatasourceByUID", + "operationId": "deleteDataSourceByUID", "parameters": [ { "type": "string", @@ -3746,8 +3703,8 @@ "/datasources/uid/{uid}/health": { "get": { "tags": ["datasources"], - "summary": "Check data source health by Id.", - "operationId": "checkDatasourceHealth", + "summary": "Sends a health check request to the plugin datasource identified by the UID.", + "operationId": "checkDatasourceHealthWithUID", "parameters": [ { "type": "string", @@ -3779,17 +3736,17 @@ "get": { "tags": ["datasources"], "summary": "Fetch data source resources.", - "operationId": "fetchDatasourceResources", + "operationId": "callDatasourceResourceWithUID", "parameters": [ { "type": "string", - "name": "uid", + "name": "datasource_proxy_route", "in": "path", "required": true }, { "type": "string", - "name": "datasource_proxy_route", + "name": "uid", "in": "path", "required": true } @@ -3893,7 +3850,7 @@ "description": "Gets all existing permissions for the data source with the given id.\n\nYou need to have a permission with action `datasources.permissions:read` and scopes `datasources:*`, `datasources:id:*`, `datasources:id:1` (single data source).", "tags": ["datasource_permissions", "enterprise"], "summary": "Get permissions for a data source.", - "operationId": "getPermissions", + "operationId": "getAllPermissions", "parameters": [ { "type": "string", @@ -3904,7 +3861,61 @@ ], "responses": { "200": { - "$ref": "#/responses/getPermissionseResponse" + "$ref": "#/responses/getAllPermissionseResponse" + }, + "401": { + "$ref": "#/responses/unauthorisedError" + }, + "403": { + "$ref": "#/responses/forbiddenError" + }, + "404": { + "$ref": "#/responses/notFoundError" + }, + "500": { + "$ref": "#/responses/internalServerError" + } + } + }, + "post": { + "description": "You need to have a permission with action `datasources.permissions:read` and scopes `datasources:*`, `datasources:id:*`, `datasources:id:1` (single data source).", + "tags": ["datasource_permissions", "enterprise"], + "summary": "Add permissions for a data source.", + "operationId": "addPermission", + "parameters": [ + { + "type": "integer", + "format": "int64", + "name": "userId", + "in": "query" + }, + { + "type": "integer", + "format": "int64", + "name": "teamId", + "in": "query" + }, + { + "type": "string", + "name": "builtinRole", + "in": "query" + }, + { + "type": "integer", + "format": "int64", + "name": "permission", + "in": "query" + }, + { + "type": "string", + "name": "datasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/addPermissionResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -3953,19 +3964,16 @@ }, "404": { "$ref": "#/responses/notFoundError" - }, - "500": { - "$ref": "#/responses/internalServerError" } } } }, "/datasources/{id}": { "get": { - "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `datasources:read` and scopes: `datasources:*`, `datasources:id:*` and `datasources:id:1` (single data source).\n\nPlease refer to [updated API](#/datasources/getDatasourceByUID) instead", + "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `datasources:read` and scopes: `datasources:*`, `datasources:id:*` and `datasources:id:1` (single data source).\n\nPlease refer to [updated API](#/datasources/getDataSourceByUID) instead", "tags": ["datasources"], "summary": "Get a single data source by Id.", - "operationId": "getDatasourceByID", + "operationId": "getDataSourceByID", "deprecated": true, "parameters": [ { @@ -3977,7 +3985,7 @@ ], "responses": { "200": { - "$ref": "#/responses/getDatasourceResponse" + "$ref": "#/responses/getDataSourceResponse" }, "400": { "$ref": "#/responses/badRequestError" @@ -3997,10 +4005,10 @@ } }, "put": { - "description": "Similar to creating a data source, `password` and `basicAuthPassword` should be defined under\nsecureJsonData in order to be stored securely as an encrypted blob in the database. Then, the\nencrypted fields are listed under secureJsonFields section in the response.\n\nIf you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `datasources:write` and scopes: `datasources:*`, `datasources:id:*` and `datasources:id:1` (single data source).\n\nPlease refer to [updated API](#/datasources/updateDatasourceByUID) instead", + "description": "Similar to creating a data source, `password` and `basicAuthPassword` should be defined under\nsecureJsonData in order to be stored securely as an encrypted blob in the database. Then, the\nencrypted fields are listed under secureJsonFields section in the response.\n\nIf you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `datasources:write` and scopes: `datasources:*`, `datasources:id:*` and `datasources:id:1` (single data source).\n\nPlease refer to [updated API](#/datasources/updateDataSourceByUID) instead", "tags": ["datasources"], "summary": "Update an existing data source by its sequential ID.", - "operationId": "updateDatasourceByID", + "operationId": "updateDataSourceByID", "deprecated": true, "parameters": [ { @@ -4034,10 +4042,10 @@ } }, "delete": { - "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `datasources:delete` and scopes: `datasources:*`, `datasources:id:*` and `datasources:id:1` (single data source).\n\nPlease refer to [updated API](#/datasources/deleteDatasourceByUID) instead", + "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `datasources:delete` and scopes: `datasources:*`, `datasources:id:*` and `datasources:id:1` (single data source).\n\nPlease refer to [updated API](#/datasources/deleteDataSourceByUID) instead", "tags": ["datasources"], "summary": "Delete an existing data source by id.", - "operationId": "deleteDatasourceByID", + "operationId": "deleteDataSourceByID", "deprecated": true, "parameters": [ { @@ -4068,9 +4076,9 @@ }, "/datasources/{id}/health": { "get": { - "description": "Please refer to [updated API](#/datasources/checkDatasourceHealth) instead", + "description": "Please refer to [updated API](#/datasources/checkDatasourceHealthWithUID) instead", "tags": ["datasources"], - "summary": "Check data source health by Id.", + "summary": "Sends a health check request to the plugin datasource identified by the ID.", "operationId": "checkDatasourceHealthByID", "deprecated": true, "parameters": [ @@ -4102,21 +4110,21 @@ }, "/datasources/{id}/resources/{datasource_proxy_route}": { "get": { - "description": "Please refer to [updated API](#/datasources/fetchDatasourceResources) instead", + "description": "Please refer to [updated API](#/datasources/callDatasourceResourceWithUID) instead", "tags": ["datasources"], "summary": "Fetch data source resources by Id.", - "operationId": "fetchDatasourceResourcesByID", + "operationId": "callDatasourceResourceByID", "deprecated": true, "parameters": [ { "type": "string", - "name": "id", + "name": "datasource_proxy_route", "in": "path", "required": true }, { "type": "string", - "name": "datasource_proxy_route", + "name": "id", "in": "path", "required": true } @@ -4147,7 +4155,7 @@ "post": { "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `datasources:query`.", "tags": ["ds"], - "summary": "Query metrics with expressions", + "summary": "DataSource query metrics with expressions", "operationId": "queryMetricsWithExpressions", "parameters": [ { @@ -4161,10 +4169,10 @@ ], "responses": { "200": { - "$ref": "#/responses/queryDataResponse" + "$ref": "#/responses/queryMetricsWithExpressionsRespons" }, "207": { - "$ref": "#/responses/queryDataResponse" + "$ref": "#/responses/queryMetricsWithExpressionsRespons" }, "400": { "$ref": "#/responses/badRequestError" @@ -4412,7 +4420,7 @@ "get": { "tags": ["folder_permissions"], "summary": "Gets all existing permissions for the folder with the given `uid`.", - "operationId": "getFolderPermissions", + "operationId": "getFolderPermissionList", "parameters": [ { "type": "string", @@ -4423,7 +4431,7 @@ ], "responses": { "200": { - "$ref": "#/responses/getDashboardPermissionsResponse" + "$ref": "#/responses/getFolderPermissionListResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -4763,10 +4771,10 @@ "get": { "tags": ["licensing", "enterprise"], "summary": "Check license availability.", - "operationId": "getLicenseStatus", + "operationId": "getStatus", "responses": { "200": { - "$ref": "#/responses/getLicenseStatusResponse" + "$ref": "#/responses/getStatusResponse" } } } @@ -4922,24 +4930,6 @@ } } }, - "/login/saml": { - "get": { - "tags": ["saml", "enterprise"], - "summary": "It initiates the login flow by redirecting the user to the IdP.", - "operationId": "getSAMLLogin", - "responses": { - "302": { - "description": "" - }, - "404": { - "$ref": "#/responses/notFoundError" - }, - "500": { - "$ref": "#/responses/internalServerError" - } - } - } - }, "/logout/saml": { "get": { "tags": ["saml", "enterprise"], @@ -4961,11 +4951,11 @@ "/org": { "get": { "description": "Get current Organization", - "tags": ["current_org_details"], - "operationId": "getOrg", + "tags": ["org"], + "operationId": "getCurrentOrg", "responses": { "200": { - "$ref": "#/responses/getOrgResponse" + "$ref": "#/responses/getCurrentOrgResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -4979,9 +4969,9 @@ } }, "put": { - "tags": ["current_org_details"], + "tags": ["org"], "summary": "Update current Organization.", - "operationId": "updateOrg", + "operationId": "updateCurrentOrg", "parameters": [ { "name": "body", @@ -5013,9 +5003,9 @@ }, "/org/address": { "put": { - "tags": ["current_org_details"], + "tags": ["org"], "summary": "Update current Organization's address.", - "operationId": "updateOrgAddress", + "operationId": "updateCurrentOrgAddress", "parameters": [ { "name": "body", @@ -5049,10 +5039,10 @@ "get": { "tags": ["org_invites"], "summary": "Get pending invites.", - "operationId": "getInvites", + "operationId": "getPendingOrgInvites", "responses": { "200": { - "$ref": "#/responses/getInvitesResponse" + "$ref": "#/responses/getPendingOrgInvitesResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -5068,7 +5058,7 @@ "post": { "tags": ["org_invites"], "summary": "Add invite.", - "operationId": "addInvite", + "operationId": "addOrgInvite", "parameters": [ { "name": "body", @@ -5081,7 +5071,7 @@ ], "responses": { "200": { - "$ref": "#/responses/addOrgUser" + "$ref": "#/responses/okResponse" }, "400": { "$ref": "#/responses/badRequestError" @@ -5101,6 +5091,38 @@ } } }, + "/org/invites/{invitation_code}/revoke": { + "delete": { + "tags": ["org_invites"], + "summary": "Revoke invite.", + "operationId": "revokeInvite", + "parameters": [ + { + "type": "string", + "name": "invitation_code", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/okResponse" + }, + "401": { + "$ref": "#/responses/unauthorisedError" + }, + "403": { + "$ref": "#/responses/forbiddenError" + }, + "404": { + "$ref": "#/responses/notFoundError" + }, + "500": { + "$ref": "#/responses/internalServerError" + } + } + } + }, "/org/preferences": { "get": { "tags": ["org_preferences"], @@ -5137,7 +5159,7 @@ ], "responses": { "200": { - "$ref": "#/responses/addOrgUser" + "$ref": "#/responses/okResponse" }, "400": { "$ref": "#/responses/badRequestError" @@ -5169,7 +5191,7 @@ ], "responses": { "200": { - "$ref": "#/responses/addOrgUser" + "$ref": "#/responses/okResponse" }, "400": { "$ref": "#/responses/badRequestError" @@ -5189,12 +5211,12 @@ "/org/users": { "get": { "description": "Returns all org users within the current organization. Accessible to users with org admin role.\nIf you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `org.users:read` with scope `users:*`.", - "tags": ["current_org_details"], + "tags": ["org"], "summary": "Get all users within the current organization.", - "operationId": "getOrgUsers", + "operationId": "getOrgUsersForCurrentOrg", "responses": { "200": { - "$ref": "#/responses/getOrgUsersResponse" + "$ref": "#/responses/getOrgUsersForCurrentOrgResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -5209,9 +5231,9 @@ }, "post": { "description": "Adds a global user to the current organization.\n\nIf you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `org.users:add` with scope `users:*`.", - "tags": ["current_org_details"], + "tags": ["org"], "summary": "Add a new user to the current organization", - "operationId": "addOrgUser", + "operationId": "addOrgUserToCurrentOrg", "parameters": [ { "name": "body", @@ -5241,9 +5263,9 @@ "/org/users/lookup": { "get": { "description": "Returns all org users within the current organization, but with less detailed information.\nAccessible to users with org admin role, admin in any folder or admin of any team.\nMainly used by Grafana UI for providing list of users when adding team members and when editing folder/dashboard permissions.", - "tags": ["current_org_details"], + "tags": ["org"], "summary": "Get all users within the current organization (lookup)", - "operationId": "lookupOrgUsers", + "operationId": "getOrgUsersForCurrentOrgLookup", "parameters": [ { "type": "string", @@ -5259,7 +5281,7 @@ ], "responses": { "200": { - "$ref": "#/responses/lookupOrgUsersResponse" + "$ref": "#/responses/getOrgUsersForCurrentOrgLookupResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -5276,9 +5298,9 @@ "/org/users/{user_id}": { "delete": { "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `org.users:remove` with scope `users:*`.", - "tags": ["current_org_details"], + "tags": ["org"], "summary": "Delete user in current organization", - "operationId": "deleteOrgUser", + "operationId": "removeOrgUserForCurrentOrg", "parameters": [ { "type": "integer", @@ -5308,9 +5330,9 @@ }, "patch": { "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `org.users.role:update` with scope `users:*`.", - "tags": ["current_org_details"], + "tags": ["org"], "summary": "Updates the given user", - "operationId": "updateOrgUser", + "operationId": "updateOrgUserForCurrentOrg", "parameters": [ { "name": "body", @@ -5347,38 +5369,6 @@ } } }, - "/org/{invitation_code}/invites": { - "delete": { - "tags": ["org_invites"], - "summary": "Revoke invite.", - "operationId": "revokeInvite", - "parameters": [ - { - "type": "string", - "name": "invitation_code", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "$ref": "#/responses/okResponse" - }, - "401": { - "$ref": "#/responses/unauthorisedError" - }, - "403": { - "$ref": "#/responses/forbiddenError" - }, - "404": { - "$ref": "#/responses/notFoundError" - }, - "500": { - "$ref": "#/responses/internalServerError" - } - } - } - }, "/orgs": { "get": { "security": [ @@ -5388,7 +5378,7 @@ ], "description": "Search all Organizations", "tags": ["orgs"], - "operationId": "searchOrg", + "operationId": "searchOrgs", "parameters": [ { "type": "integer", @@ -5419,7 +5409,7 @@ ], "responses": { "200": { - "$ref": "#/responses/searchOrgResponse" + "$ref": "#/responses/searchOrgsResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -5489,7 +5479,7 @@ ], "responses": { "200": { - "$ref": "#/responses/getOrgResponse" + "$ref": "#/responses/getOrgByNameResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -5524,7 +5514,7 @@ ], "responses": { "200": { - "$ref": "#/responses/getOrgResponse" + "$ref": "#/responses/getOrgByIDResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -5545,7 +5535,7 @@ ], "tags": ["orgs"], "summary": "Update Organization.", - "operationId": "adminUpdateOrg", + "operationId": "updateOrg", "parameters": [ { "name": "body", @@ -5589,7 +5579,7 @@ ], "tags": ["orgs"], "summary": "Delete Organization.", - "operationId": "adminDeleteOrg", + "operationId": "deleteOrgByID", "parameters": [ { "type": "integer", @@ -5625,7 +5615,7 @@ "put": { "tags": ["orgs"], "summary": "Update Organization's address.", - "operationId": "adminUpdateOrgAddress", + "operationId": "updateOrgAddress", "parameters": [ { "name": "body", @@ -5759,7 +5749,7 @@ "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `org.users:read` with scope `users:*`.", "tags": ["orgs"], "summary": "Get Users in Organization.", - "operationId": "adminGetOrgUsers", + "operationId": "getOrgUsers", "parameters": [ { "type": "integer", @@ -5788,7 +5778,7 @@ "description": "Adds a global user to the current organization.\n\nIf you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `org.users:add` with scope `users:*`.", "tags": ["orgs"], "summary": "Add a new user to the current organization", - "operationId": "adminAddOrgUser", + "operationId": "addOrgUser", "parameters": [ { "name": "body", @@ -5827,7 +5817,7 @@ "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `org.users:remove` with scope `users:*`.", "tags": ["orgs"], "summary": "Delete user in current organization", - "operationId": "adminDeleteOrgUser", + "operationId": "removeOrgUser", "parameters": [ { "type": "integer", @@ -5866,7 +5856,7 @@ "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled\nyou need to have a permission with action: `org.users.role:update` with scope `users:*`.", "tags": ["orgs"], "summary": "Update Users in Organization.", - "operationId": "adminUpdateOrgUser", + "operationId": "updateOrgUser", "parameters": [ { "name": "body", @@ -5974,7 +5964,7 @@ "/playlists/{uid}": { "get": { "tags": ["playlists"], - "summary": "Get playlist by UID.", + "summary": "Get playlist.", "operationId": "getPlaylist", "parameters": [ { @@ -6042,7 +6032,7 @@ }, "delete": { "tags": ["playlists"], - "summary": "Delete pllaylist.", + "summary": "Delete playlist.", "operationId": "deletePlaylist", "parameters": [ { @@ -6393,8 +6383,8 @@ }, "/recording-rules": { "get": { + "description": "Lists all rules in the database: active or deleted", "tags": ["recording_rules", "enterprise"], - "summary": "Get all recording rules.", "operationId": "listRecordingRules", "responses": { "200": { @@ -6415,8 +6405,8 @@ } }, "put": { + "description": "Update the active status of a rule", "tags": ["recording_rules", "enterprise"], - "summary": "Update a recording rule.", "operationId": "updateRecordingRule", "parameters": [ { @@ -6447,8 +6437,8 @@ } }, "post": { + "description": "Create a recording rule that is then registered and started", "tags": ["recording_rules", "enterprise"], - "summary": "Create a new recording rule.", "operationId": "createRecordingRule", "parameters": [ { @@ -6518,8 +6508,8 @@ }, "/recording-rules/writer": { "get": { + "description": "Return the prometheus remote write target", "tags": ["recording_rules", "enterprise"], - "summary": "Get the write target.", "operationId": "getRecordingRuleWriteTarget", "responses": { "200": { @@ -6540,8 +6530,9 @@ } }, "post": { + "description": "It returns a 422 if there is not an existing prometheus data source configured", "tags": ["recording_rules", "enterprise"], - "summary": "Create a new write target.", + "summary": "Create a remote write target.", "operationId": "createRecordingRuleWriteTarget", "parameters": [ { @@ -6576,7 +6567,7 @@ }, "delete": { "tags": ["recording_rules", "enterprise"], - "summary": "Delete the write target.", + "summary": "Delete the remote write target.", "operationId": "deleteRecordingRuleWriteTarget", "responses": { "200": { @@ -6600,7 +6591,7 @@ "/recording-rules/{recordingRuleID}": { "delete": { "tags": ["recording_rules", "enterprise"], - "summary": "Delete a recording rule.", + "summary": "Delete removes the rule from the registry and stops it.", "operationId": "deleteRecordingRule", "parameters": [ { @@ -6726,7 +6717,7 @@ } } }, - "/reports/render/pdf/{DashboardID}": { + "/reports/render/pdf/{dashboardID}": { "get": { "description": "Please refer to [reports enterprise](#/reports/renderReportPDFs) instead. This will be removed in Grafana 10.", "produces": ["application/pdf"], @@ -6741,6 +6732,43 @@ "name": "DashboardID", "in": "path", "required": true + }, + { + "type": "integer", + "format": "int64", + "name": "dashboardID", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "title", + "in": "query" + }, + { + "type": "string", + "name": "variables", + "in": "query" + }, + { + "type": "string", + "name": "from", + "in": "query" + }, + { + "type": "string", + "name": "to", + "in": "query" + }, + { + "type": "string", + "name": "orientation", + "in": "query" + }, + { + "type": "string", + "name": "layout", + "in": "query" } ], "responses": { @@ -6766,6 +6794,23 @@ "tags": ["reports", "enterprise"], "summary": "Render report for multiple dashboards.", "operationId": "renderReportPDFs", + "parameters": [ + { + "type": "string", + "name": "dashboardID", + "in": "query" + }, + { + "type": "string", + "name": "orientation", + "in": "query" + }, + { + "type": "string", + "name": "layout", + "in": "query" + } + ], "responses": { "200": { "$ref": "#/responses/contentResponse" @@ -6875,7 +6920,7 @@ } } }, - "/reports/{reportID}": { + "/reports/{id}": { "get": { "description": "Available to org admins only and with a valid or expired license\n\nYou need to have a permission with action `reports:read` with scope `reports:id:\u003creport ID\u003e`.", "tags": ["reports", "enterprise"], @@ -6885,7 +6930,7 @@ { "type": "integer", "format": "int64", - "name": "reportID", + "name": "id", "in": "path", "required": true } @@ -6928,7 +6973,7 @@ { "type": "integer", "format": "int64", - "name": "reportID", + "name": "id", "in": "path", "required": true } @@ -6963,7 +7008,7 @@ { "type": "integer", "format": "int64", - "name": "reportID", + "name": "id", "in": "path", "required": true } @@ -7020,7 +7065,7 @@ "produces": ["application/xml;application/samlmetadata+xml"], "tags": ["saml", "enterprise"], "summary": "It exposes the SP (Grafana's) metadata for the IdP's consumption.", - "operationId": "getSAMLMetadata", + "operationId": "getMetadata", "responses": { "200": { "$ref": "#/responses/contentResponse" @@ -7030,6 +7075,7 @@ }, "/saml/slo": { "post": { + "description": "There might be two possible requests:\n1. Logout response (callback) when Grafana initiates single logout and IdP returns response to logout request.\n2. Logout request when another SP initiates single logout and IdP sends logout request to the Grafana,\nor in case of IdP-initiated logout.", "tags": ["saml", "enterprise"], "summary": "It performs Single Logout (SLO) callback.", "operationId": "postSLO", @@ -7175,10 +7221,10 @@ "get": { "description": "List search sorting options", "tags": ["search"], - "operationId": "searchSorting", + "operationId": "listSortOptions", "responses": { "200": { - "$ref": "#/responses/searchSortingResponse" + "$ref": "#/responses/listSortOptionsResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -7224,7 +7270,7 @@ "get": { "description": "Required permissions (See note in the [introduction](https://grafana.com/docs/grafana/latest/developers/http_api/serviceaccount/#service-account-api) for an explanation):\naction: `serviceaccounts:read` scope: `serviceaccounts:*`", "tags": ["service_accounts"], - "summary": "Search service accounts with Paging", + "summary": "Search service accounts with paging", "operationId": "searchOrgServiceAccountsWithPaging", "parameters": [ { @@ -7421,7 +7467,7 @@ "post": { "description": "Required permissions (See note in the [introduction](https://grafana.com/docs/grafana/latest/developers/http_api/serviceaccount/#service-account-api) for an explanation):\naction: `serviceaccounts:write` scope: `serviceaccounts:id:1` (single service account)", "tags": ["service_accounts"], - "summary": "Create service account tokens", + "summary": "CreateNewToken adds a token to a service account", "operationId": "createToken", "parameters": [ { @@ -7468,7 +7514,7 @@ "delete": { "description": "Required permissions (See note in the [introduction](https://grafana.com/docs/grafana/latest/developers/http_api/serviceaccount/#service-account-api) for an explanation):\naction: `serviceaccounts:write` scope: `serviceaccounts:id:1` (single service account)\n\nRequires basic authentication and that the authenticated user is a Grafana Admin.", "tags": ["service_accounts"], - "summary": "Delete service account tokens", + "summary": "DeleteToken deletes service account tokens", "operationId": "deleteToken", "parameters": [ { @@ -7512,10 +7558,10 @@ "get": { "tags": ["snapshots"], "summary": "Get snapshot sharing settings.", - "operationId": "getSnapshotSharingOptions", + "operationId": "getSharingOptions", "responses": { "200": { - "$ref": "#/responses/getSnapshotSharingOptionsResponse" + "$ref": "#/responses/getSharingOptionsResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -7528,7 +7574,7 @@ "description": "Snapshot public mode should be enabled or authentication is required.", "tags": ["snapshots"], "summary": "When creating a snapshot using the API, you have to provide the full dashboard payload including the snapshot data. This endpoint is designed for the Grafana UI.", - "operationId": "createSnapshot", + "operationId": "createDashboardSnapshot", "parameters": [ { "name": "body", @@ -7541,7 +7587,7 @@ ], "responses": { "200": { - "$ref": "#/responses/createSnapshotResponse" + "$ref": "#/responses/createDashboardSnapshotResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -7560,7 +7606,7 @@ "description": "Snapshot public mode should be enabled or authentication is required.", "tags": ["snapshots"], "summary": "Delete Snapshot by deleteKey.", - "operationId": "deleteSnapshotByDeleteKey", + "operationId": "deleteDashboardSnapshotByDeleteKey", "parameters": [ { "type": "string", @@ -7592,7 +7638,7 @@ "get": { "tags": ["snapshots"], "summary": "Get Snapshot by Key.", - "operationId": "getSnapshotByKey", + "operationId": "getDashboardSnapshot", "parameters": [ { "type": "string", @@ -7603,7 +7649,7 @@ ], "responses": { "200": { - "$ref": "#/responses/snapshotResponse" + "$ref": "#/responses/getDashboardSnapshotResponse" }, "404": { "$ref": "#/responses/notFoundError" @@ -7616,7 +7662,7 @@ "delete": { "tags": ["snapshots"], "summary": "Delete Snapshot by Key.", - "operationId": "deleteSnapshotByKey", + "operationId": "deleteDashboardSnapshot", "parameters": [ { "type": "string", @@ -7848,7 +7894,7 @@ "get": { "tags": ["teams"], "summary": "Get Team By ID.", - "operationId": "getTeam", + "operationId": "getTeamByID", "parameters": [ { "type": "string", @@ -7859,7 +7905,7 @@ ], "responses": { "200": { - "$ref": "#/responses/getTeamResponse" + "$ref": "#/responses/getTeamByIDResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -8164,8 +8210,8 @@ }, "/user": { "get": { + "description": "Get (current authenticated user)", "tags": ["signed_in_user"], - "summary": "Get signed in User.", "operationId": "getSignedInUser", "responses": { "200": { @@ -8202,7 +8248,7 @@ ], "responses": { "200": { - "$ref": "#/responses/userResponse" + "$ref": "#/responses/okResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -8221,10 +8267,10 @@ "description": "Return a list of all auth tokens (devices) that the actual user currently have logged in from.", "tags": ["signed_in_user"], "summary": "Auth tokens of the actual User.", - "operationId": "getSignedInUserAuthTokens", + "operationId": "getUserAuthTokens", "responses": { "200": { - "$ref": "#/responses/getAuthTokensResponse" + "$ref": "#/responses/getUserAuthTokensResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -8301,7 +8347,7 @@ "operationId": "getSignedInUserOrgList", "responses": { "200": { - "$ref": "#/responses/getUserOrgListResponse" + "$ref": "#/responses/getSignedInUserOrgListResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -8462,7 +8508,7 @@ "description": "Revokes the given auth token (device) for the actual user. User of issued auth token (device) will no longer be logged in and will be required to authenticate again upon next activity.", "tags": ["signed_in_user"], "summary": "Revoke an auth token of the actual User.", - "operationId": "revokeSignedInAuthToken", + "operationId": "revokeUserAuthToken", "parameters": [ { "name": "body", @@ -8564,7 +8610,7 @@ "operationId": "getSignedInUserTeamList", "responses": { "200": { - "$ref": "#/responses/getUserOrgListResponse" + "$ref": "#/responses/getSignedInUserTeamListResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -8766,7 +8812,7 @@ ], "responses": { "200": { - "$ref": "#/responses/userResponse" + "$ref": "#/responses/okResponse" }, "401": { "$ref": "#/responses/unauthorisedError" @@ -9677,7 +9723,7 @@ } } }, - "CreateCorrelationResponse": { + "CreateCorrelationResponseBody": { "description": "CreateCorrelationResponse is the response struct for CreateCorrelationCommand", "type": "object", "properties": { @@ -10639,7 +10685,7 @@ "type": "string", "title": "DataTopic is used to identify which topic the frame should be assigned to." }, - "DeleteCorrelationResponse": { + "DeleteCorrelationResponseBody": { "type": "object", "properties": { "message": { @@ -13871,32 +13917,64 @@ "$ref": "#/definitions/ErrorResponseBody" } }, - "addOrgUser": { + "addPermissionResponse": { "description": "", "schema": { "type": "object", - "required": ["id", "message"], "properties": { - "id": { - "description": "ID Identifier of the added user.", - "type": "integer", - "format": "int64", - "example": 65 - }, "message": { - "description": "Message Message of the added user.", - "type": "string", - "example": "Data source added" + "type": "string" + }, + "permissionId": { + "type": "integer", + "format": "int64" } } } }, + "adminCreateUserResponse": { + "description": "", + "schema": { + "$ref": "#/definitions/UserIdDTO" + } + }, + "adminGetSettingsResponse": { + "description": "", + "schema": { + "$ref": "#/definitions/SettingsBag" + } + }, + "adminGetStatsResponse": { + "description": "", + "schema": { + "$ref": "#/definitions/AdminStats" + } + }, + "adminGetUserAuthTokensResponse": { + "description": "", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/UserToken" + } + } + }, "badRequestError": { "description": "BadRequestError is returned when the request is invalid and it cannot be processed.", "schema": { "$ref": "#/definitions/ErrorResponseBody" } }, + "calculateDashboardDiffResponse": { + "description": "", + "schema": { + "type": "array", + "items": { + "type": "integer", + "format": "uint8" + } + } + }, "conflictError": { "description": "ConflictError", "schema": { @@ -13913,29 +13991,37 @@ } } }, - "createAnnotationResponse": { - "description": "", - "schema": { - "type": "object", - "required": ["id", "message"], - "properties": { - "id": { - "description": "ID Identifier of the created annotation.", - "type": "integer", - "format": "int64", - "example": 65 - }, - "message": { - "description": "Message Message of the created annotation.", - "type": "string" - } - } - } - }, "createCorrelationResponse": { "description": "", "schema": { - "$ref": "#/definitions/CreateCorrelationResponse" + "$ref": "#/definitions/CreateCorrelationResponseBody" + } + }, + "createDashboardSnapshotResponse": { + "description": "", + "schema": { + "type": "object", + "properties": { + "deleteKey": { + "description": "Unique key used to delete the snapshot. It is different from the key so that only the creator can delete the snapshot.", + "type": "string" + }, + "deleteUrl": { + "type": "string" + }, + "id": { + "description": "Snapshot id", + "type": "integer", + "format": "int64" + }, + "key": { + "description": "Unique key", + "type": "string" + }, + "url": { + "type": "string" + } + } } }, "createOrUpdateDatasourceResponse": { @@ -14007,39 +14093,18 @@ } } }, + "createRoleResponse": { + "description": "", + "schema": { + "$ref": "#/definitions/RoleDTO" + } + }, "createServiceAccountResponse": { "description": "", "schema": { "$ref": "#/definitions/ServiceAccountDTO" } }, - "createSnapshotResponse": { - "description": "", - "schema": { - "type": "object", - "properties": { - "deleteKey": { - "description": "Unique key used to delete the snapshot. It is different from the key so that only the creator can delete the snapshot.", - "type": "string" - }, - "deleteUrl": { - "type": "string" - }, - "id": { - "description": "Snapshot id", - "type": "integer", - "format": "int64" - }, - "key": { - "description": "Unique key", - "type": "string" - }, - "url": { - "type": "string" - } - } - } - }, "createTeamResponse": { "description": "", "schema": { @@ -14061,22 +14126,6 @@ "$ref": "#/definitions/NewApiKeyResult" } }, - "createUserResponse": { - "description": "", - "schema": { - "$ref": "#/definitions/UserIdDTO" - } - }, - "dashboardDiffResponse": { - "description": "Calculate dashboard diff response.", - "schema": { - "type": "array", - "items": { - "type": "integer", - "format": "uint8" - } - } - }, "dashboardResponse": { "description": "", "schema": { @@ -14098,15 +14147,6 @@ } } }, - "dashboardsTagsResponse": { - "description": "", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/DashboardTagCloudItem" - } - } - }, "deleteAlertNotificationChannelResponse": { "description": "", "schema": { @@ -14129,7 +14169,7 @@ "deleteCorrelationResponse": { "description": "", "schema": { - "$ref": "#/definitions/DeleteCorrelationResponse" + "$ref": "#/definitions/DeleteCorrelationResponseBody" } }, "deleteDashboardResponse": { @@ -14157,7 +14197,7 @@ } } }, - "deleteDatasourceByNameResponse": { + "deleteDataSourceByNameResponse": { "description": "", "schema": { "type": "object", @@ -14250,6 +14290,15 @@ } } }, + "getAlertNotificationLookupResponse": { + "description": "", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/AlertNotificationLookup" + } + } + }, "getAlertResponse": { "description": "", "schema": { @@ -14265,6 +14314,12 @@ } } }, + "getAllPermissionseResponse": { + "description": "", + "schema": { + "$ref": "#/definitions/DataSourcePermissionsDTO" + } + }, "getAllRolesResponse": { "description": "", "schema": { @@ -14274,7 +14329,7 @@ } } }, - "getAnnotationResponse": { + "getAnnotationByIDResponse": { "description": "", "schema": { "$ref": "#/definitions/ItemDTO" @@ -14295,13 +14350,10 @@ } } }, - "getAuthTokensResponse": { + "getCurrentOrgResponse": { "description": "", "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/UserToken" - } + "$ref": "#/definitions/OrgDetailsDTO" } }, "getCustomPermissionsReportResponse": { @@ -14313,7 +14365,7 @@ } } }, - "getDashboardPermissionsResponse": { + "getDashboardPermissionsListResponse": { "description": "", "schema": { "type": "array", @@ -14322,6 +14374,9 @@ } } }, + "getDashboardSnapshotResponse": { + "description": "" + }, "getDashboardStatesResponse": { "description": "", "schema": { @@ -14331,7 +14386,16 @@ } } }, - "getDatasourceIDresponse": { + "getDashboardsTagsResponse": { + "description": "", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/DashboardTagCloudItem" + } + } + }, + "getDataSourceIDResponse": { "description": "", "schema": { "type": "object", @@ -14346,18 +14410,27 @@ } } }, - "getDatasourceResponse": { + "getDataSourceResponse": { "description": "", "schema": { "$ref": "#/definitions/DataSource" } }, - "getDatasourcesResponse": { + "getDataSourcesResponse": { "description": "", "schema": { "$ref": "#/definitions/DataSourceList" } }, + "getFolderPermissionListResponse": { + "description": "", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/DashboardACLInfoDTO" + } + } + }, "getFoldersResponse": { "description": "", "schema": { @@ -14368,26 +14441,11 @@ } }, "getHomeDashboardResponse": { - "description": "Home dashboard response.", + "description": "", "schema": { "$ref": "#/definitions/GetHomeDashboardResponse" } }, - "getInvitesResponse": { - "description": "", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/TempUserDTO" - } - } - }, - "getLDAPSyncStatusResponse": { - "description": "", - "schema": { - "$ref": "#/definitions/ActiveSyncStatusDTO" - } - }, "getLibraryElementConnectionsResponse": { "description": "", "schema": { @@ -14406,21 +14464,42 @@ "$ref": "#/definitions/LibraryElementSearchResponse" } }, - "getLicenseStatusResponse": { - "description": "" - }, "getLicenseTokenResponse": { "description": "", "schema": { "$ref": "#/definitions/Token" } }, - "getOrgResponse": { + "getOrgByIDResponse": { "description": "", "schema": { "$ref": "#/definitions/OrgDetailsDTO" } }, + "getOrgByNameResponse": { + "description": "", + "schema": { + "$ref": "#/definitions/OrgDetailsDTO" + } + }, + "getOrgUsersForCurrentOrgLookupResponse": { + "description": "", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/UserLookupDTO" + } + } + }, + "getOrgUsersForCurrentOrgResponse": { + "description": "", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/OrgUserDTO" + } + } + }, "getOrgUsersResponse": { "description": "", "schema": { @@ -14430,10 +14509,13 @@ } } }, - "getPermissionseResponse": { + "getPendingOrgInvitesResponse": { "description": "", "schema": { - "$ref": "#/definitions/DataSourcePermissionsDTO" + "type": "array", + "items": { + "$ref": "#/definitions/TempUserDTO" + } } }, "getPlaylistDashboardsResponse": { @@ -14523,13 +14605,7 @@ "$ref": "#/definitions/RoleDTO" } }, - "getSettingsResponse": { - "description": "", - "schema": { - "$ref": "#/definitions/SettingsBag" - } - }, - "getSnapshotSharingOptionsResponse": { + "getSharingOptionsResponse": { "description": "", "schema": { "type": "object", @@ -14546,19 +14622,37 @@ } } }, - "getSnapshotsResponse": { + "getSignedInUserOrgListResponse": { "description": "", "schema": { "type": "array", "items": { - "$ref": "#/definitions/DashboardSnapshotDTO" + "$ref": "#/definitions/UserOrgDTO" } } }, - "getStatsResponse": { + "getSignedInUserTeamListResponse": { "description": "", "schema": { - "$ref": "#/definitions/AdminStats" + "type": "array", + "items": { + "$ref": "#/definitions/TeamDTO" + } + } + }, + "getStatusResponse": { + "description": "" + }, + "getSyncStatusResponse": { + "description": "", + "schema": { + "$ref": "#/definitions/ActiveSyncStatusDTO" + } + }, + "getTeamByIDResponse": { + "description": "", + "schema": { + "$ref": "#/definitions/TeamDTO" } }, "getTeamGroupsApiResponse": { @@ -14579,10 +14673,13 @@ } } }, - "getTeamResponse": { + "getUserAuthTokensResponse": { "description": "", "schema": { - "$ref": "#/definitions/TeamDTO" + "type": "array", + "items": { + "$ref": "#/definitions/UserToken" + } } }, "getUserOrgListResponse": { @@ -14651,30 +14748,41 @@ } } }, + "listRolesResponse": { + "description": "", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/RoleDTO" + } + } + }, + "listSortOptionsResponse": { + "description": "", + "schema": { + "type": "object", + "properties": { + "description": { + "type": "string" + }, + "displayName": { + "type": "string" + }, + "meta": { + "type": "string" + }, + "name": { + "type": "string" + } + } + } + }, "listTokensResponse": { "description": "", "schema": { "$ref": "#/definitions/TokenDTO" } }, - "lookupAlertNotificationChannelsResponse": { - "description": "", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/AlertNotificationLookup" - } - } - }, - "lookupOrgUsersResponse": { - "description": "", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/UserLookupDTO" - } - } - }, "notFoundError": { "description": "NotFoundError is returned when the requested resource was not found.", "schema": { @@ -14734,8 +14842,27 @@ "$ref": "#/definitions/NewApiKeyResult" } }, + "postAnnotationResponse": { + "description": "", + "schema": { + "type": "object", + "required": ["id", "message"], + "properties": { + "id": { + "description": "ID Identifier of the created annotation.", + "type": "integer", + "format": "int64", + "example": 65 + }, + "message": { + "description": "Message Message of the created annotation.", + "type": "string" + } + } + } + }, "postDashboardResponse": { - "description": "Create/update dashboard response.", + "description": "", "schema": { "type": "object", "required": ["status", "title", "version", "id", "uid", "url"], @@ -14783,7 +14910,7 @@ "$ref": "#/definitions/ErrorResponseBody" } }, - "queryDataResponse": { + "queryMetricsWithExpressionsRespons": { "description": "", "schema": { "$ref": "#/definitions/QueryDataResponse" @@ -14813,12 +14940,12 @@ "$ref": "#/definitions/ServiceAccountDTO" } }, - "searchOrgResponse": { + "searchDashboardSnapshotsResponse": { "description": "", "schema": { "type": "array", "items": { - "$ref": "#/definitions/OrgDTO" + "$ref": "#/definitions/DashboardSnapshotDTO" } } }, @@ -14828,6 +14955,15 @@ "$ref": "#/definitions/SearchServiceAccountsResult" } }, + "searchOrgsResponse": { + "description": "", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/OrgDTO" + } + } + }, "searchPlaylistsResponse": { "description": "", "schema": { @@ -14840,26 +14976,6 @@ "$ref": "#/definitions/HitList" } }, - "searchSortingResponse": { - "description": "", - "schema": { - "type": "object", - "properties": { - "description": { - "type": "string" - }, - "displayName": { - "type": "string" - }, - "meta": { - "type": "string" - }, - "name": { - "type": "string" - } - } - } - }, "searchTeamsResponse": { "description": "", "schema": { @@ -14872,9 +14988,6 @@ "$ref": "#/definitions/SearchUserQueryResult" } }, - "snapshotResponse": { - "description": "" - }, "testAlertResponse": { "description": "", "schema": { @@ -14882,7 +14995,7 @@ } }, "trimDashboardResponse": { - "description": "Trimmed dashboard response.", + "description": "", "schema": { "$ref": "#/definitions/TrimDashboardFullWithMeta" } @@ -14994,7 +15107,7 @@ }, { "description": "If you are running Grafana Enterprise and have Fine-grained access control enabled, for some endpoints you would need to have relevant permissions. Refer to specific resources to understand what permissions are required.", - "name": "current_org_details" + "name": "org" }, { "description": "This API can be used to create/update/delete Teams and to add/remove users to Teams. All actions require that the user has the Admin role for the organization.",