grafana/pkg/api
Agnès Toulet fdaf6e3f2e
PublicDashboards: Add setting to disable the feature (#78894)
* Replace feature toggle with configuration setting

* Fix permission alert

* Update documentation

* Add back feature toggle

* revert unwanted commited changes

* fix tests

* run prettier

* Update SharePublicDashboard.test.tsx

* fix linter and frontend tests

* Update api.go

* Apply docs edit from code review

Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com>

* Update index.md

* Update docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md

Co-authored-by: Agnès Toulet <35176601+AgnesToulet@users.noreply.github.com>

* Update docs/sources/setup-grafana/configure-grafana/_index.md

Co-authored-by: Agnès Toulet <35176601+AgnesToulet@users.noreply.github.com>

* add isPublicDashboardsEnabled + test

* fix test

* update ff description in registry

* move isPublicDashboardsEnabled

* revert getConfig() update

---------

Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com>
Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com>
2023-12-19 11:43:54 +01:00
..
apierrors Alerting: Fix deleting rules in a folder with matching UID in another organization (#78258) 2023-12-04 11:34:38 +02:00
avatar
datasource mssql: prepare logs-handling for decouple-datasource changes (#79214) 2023-12-11 09:14:06 +01:00
dtos PublicDashboards: Add setting to disable the feature (#78894) 2023-12-19 11:43:54 +01:00
frontendlogging
pluginproxy
response
routing
static
webassets Frontend: Foundations for multi tenant frontend (#78815) 2023-12-05 08:34:22 +01:00
README.md Swagger: Show k8s APIs (#78091) 2023-11-15 06:42:35 -08:00
accesscontrol.go RBAC: change annotation scopes back (#79330) 2023-12-12 09:51:08 +02:00
admin.go Anonymous: Add device limits to stats (#79494) 2023-12-18 09:32:57 +01:00
admin_encryption.go
admin_provisioning.go
admin_provisioning_test.go
admin_test.go Auth: Add anonymous users view and stats (#78685) 2023-11-29 17:58:41 +01:00
admin_users.go Chore: Configure SkipOrgRoleSync from OAuthInfo for OAuth connectors (#79443) 2023-12-15 10:58:08 +01:00
admin_users_test.go Chore: Configure SkipOrgRoleSync from OAuthInfo for OAuth connectors (#79443) 2023-12-15 10:58:08 +01:00
alerting.go Authz: Remove use of SignedInUser copy for permission evaluation (#78448) 2023-11-22 14:20:22 +01:00
annotations.go Annotations: Remove dashboard permission checks for annotations (#78352) 2023-11-23 10:47:37 +00:00
annotations_test.go Annotations: Remove dashboard permission checks for annotations (#78352) 2023-11-23 10:47:37 +00:00
api.go PublicDashboards: Add setting to disable the feature (#78894) 2023-12-19 11:43:54 +01:00
apikey.go
basic_auth.go
basic_auth_test.go
common_test.go Auth: Split signout_redirect_url into per provider settings (#75269) 2023-11-29 14:50:21 +01:00
dashboard.go PublicDashboards: Add setting to disable the feature (#78894) 2023-12-19 11:43:54 +01:00
dashboard_permission.go Authz: Remove use of SignedInUser copy for permission evaluation (#78448) 2023-11-22 14:20:22 +01:00
dashboard_permission_test.go
dashboard_snapshot.go
dashboard_snapshot_test.go
dashboard_test.go PublicDashboards: Add setting to disable the feature (#78894) 2023-12-19 11:43:54 +01:00
dataproxy.go
datasources.go Team LBAC: Limit access to data source (#78376) 2023-12-05 13:45:40 +02:00
datasources_test.go Team LBAC: Limit access to data source (#78376) 2023-12-05 13:45:40 +02:00
fakes.go Plugins: Make renderer service load renderer plugin (#77854) 2023-12-14 17:33:29 +01:00
featuremgmt.go Feature Toggles: Remove use of boolPtr in FeatureFlag struct (#79550) 2023-12-18 13:55:21 -05:00
featuremgmt_test.go Feature Toggles: Remove use of boolPtr in FeatureFlag struct (#79550) 2023-12-18 13:55:21 -05:00
folder.go Fix capitalising Folder structs (#79207) 2023-12-07 13:15:58 +01:00
folder_bench_test.go Chore: Remove redundant benchmarks (#79626) 2023-12-18 11:31:25 +02:00
folder_permission.go Authz: Remove use of SignedInUser copy for permission evaluation (#78448) 2023-11-22 14:20:22 +01:00
folder_permission_test.go Chore: Deprecate ID from Folder (#78281) 2023-11-20 15:44:51 -05:00
folder_test.go Chore: Remove FolderID from DTO Folder (#78420) 2023-12-07 13:56:04 +01:00
frontend_logging.go
frontend_logging_test.go
frontend_metrics.go
frontendsettings.go PublicDashboards: Add setting to disable the feature (#78894) 2023-12-19 11:43:54 +01:00
frontendsettings_test.go Plugins: Make renderer service load renderer plugin (#77854) 2023-12-14 17:33:29 +01:00
grafana_com_proxy.go
health.go
health_test.go
http_server.go K8s: Refactor metrics to share k8s registry (#79106) 2023-12-06 16:34:23 -05:00
http_server_test.go
index.go Analytics: Return empty analytic settings for users that are not signed in (#79515) 2023-12-14 16:17:48 +01:00
login.go Authn: Handle logout logic in auth broker (#79635) 2023-12-19 10:17:28 +01:00
login_oauth.go
login_oauth_test.go
login_test.go Frontend: Foundations for multi tenant frontend (#78815) 2023-12-05 08:34:22 +01:00
metrics.go
metrics_test.go
org.go
org_invite.go
org_invite_test.go
org_test.go
org_users.go Chore: Configure SkipOrgRoleSync from OAuthInfo for OAuth connectors (#79443) 2023-12-15 10:58:08 +01:00
org_users_test.go Chore: Configure SkipOrgRoleSync from OAuthInfo for OAuth connectors (#79443) 2023-12-15 10:58:08 +01:00
password.go
playlist.go K8s: Add resource type helper to avoid so many hardcoded names (#79344) 2023-12-11 22:03:48 +02:00
plugin_checks.go Chore: Evaluate if an app is disabled for API requests (#79564) 2023-12-15 16:37:39 +01:00
plugin_checks_test.go Chore: Evaluate if an app is disabled for API requests (#79564) 2023-12-15 16:37:39 +01:00
plugin_dashboards.go
plugin_dashboards_test.go Chore: Evaluate if an app is disabled for API requests (#79564) 2023-12-15 16:37:39 +01:00
plugin_metrics.go
plugin_metrics_test.go
plugin_proxy.go
plugin_proxy_test.go
plugin_resource.go
plugin_resource_test.go Plugins: Add Grafana config to app plugin context (#79439) 2023-12-13 10:28:24 +01:00
plugins.go Plugins: Rename `externalServiceAuthentication` to `iam` (#78686) 2023-12-04 13:14:21 +01:00
plugins_test.go Plugins: Rename `externalServiceAuthentication` to `iam` (#78686) 2023-12-04 13:14:21 +01:00
preferences.go
preferences_test.go
quota.go
quota_test.go
render.go Export: Remove no-store headers in pdf and image previews (#78844) 2023-12-18 09:21:57 -03:00
search.go Authz: Remove use of SignedInUser copy for permission evaluation (#78448) 2023-11-22 14:20:22 +01:00
short_url.go
short_url_test.go
signup.go
swagger.go Swagger: Show k8s APIs (#78091) 2023-11-15 06:42:35 -08:00
swagger_responses.go
swagger_tags.json
user.go Chore: Configure SkipOrgRoleSync from OAuthInfo for OAuth connectors (#79443) 2023-12-15 10:58:08 +01:00
user_test.go Chore: Configure SkipOrgRoleSync from OAuthInfo for OAuth connectors (#79443) 2023-12-15 10:58:08 +01:00
user_token.go Auth: Add more context to logs around token rotation, revocation (#78600) 2023-11-23 16:48:54 +01:00
user_token_test.go
utils.go

README.md

OpenAPI specifications

Since version 8.4, HTTP API details are specified using OpenAPI v2. Starting from version 9.1, there is also an OpenAPI v3 specification (generated by the v2 one using this script).

OpenAPI annotations

The OpenAPI v2 specification is generated automatically from the annotated Go code using go-swagger which scans the source code for annotation rules. Refer to this getting started guide for getting familiar with the toolkit.

Developers modifying the HTTP API endpoints need to make sure to add the necessary annotations so that their changes are reflected into the generated specifications.

Example of endpoint annotation

The following route defines a PATCH endpoint under the /serviceaccounts/{serviceAccountId} path with tag service_accounts (used for grouping together several routes) and operation ID updateServiceAccount (used for uniquely identifying routes and associate parameters and response with them).


// 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

The go-swagger can discover such annotations by scanning any code imported by pkg/server but by convention we place the endpoint annotations above the endpoint definition.

Example of endpoint parameters

The following struct defines the route parameters for the updateServiceAccount endpoint. The route expects:

  • a path parameter denoting the service account identifier and
  • a body parameter with the new values for the specific service account

// swagger:parameters updateServiceAccount
type UpdateServiceAccountParams struct {
	// in:path
	ServiceAccountId int64 `json:"serviceAccountId"`
	// in:body
	Body serviceaccounts.UpdateServiceAccountForm
}

Example of endpoint response

The following struct defines the response for the updateServiceAccount endpoint in case of a successful 200 response.


// 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"`
	}
}

OpenAPI generation

Developers can re-create the OpenAPI v2 and v3 specifications using the following command:


make swagger-clean && make openapi3-gen

They can observe its output into the public/api-merged.json and public/openapi3.json files.

Finally, they can browser and try out both the OpenAPI v2 and v3 via the Swagger UI editor (served by the grafana server) by navigating to /swagger.