@@ -135,6 +135,25 @@ grafana = GrafanaApi.from_env()
135
135
Please note that, on top of the specific examples above, the object obtained by
136
136
` credential ` can be an arbitrary ` requests.auth.AuthBase ` instance.
137
137
138
+ ## Selecting Organizations
139
+
140
+ If the Grafana API is authenticated as a user (for example, with HTTP Basic Authentication),
141
+ it will use the user's current organization context.
142
+ That context can be changed with the ` GrafanaApi.user.switch_actual_user_organisation ` function.
143
+
144
+ ``` python
145
+ grafana.user.switch_actual_user_organisation(1 )
146
+ ```
147
+
148
+ An instance of ` GrafanaApi ` can also be bound to a single organization with the ` organization_id ` parameter,
149
+ ensuring that all requests will be made to that organization.
150
+ This parameter will cause ` GrafanaClient ` to use the [ X-Grafana-Org-Id header] .
151
+
152
+ ``` python
153
+ grafana = GrafanaApi(... , organization_id = 1 )
154
+ ```
155
+
156
+ API Tokens are bound to a single organization, so the ` organization_id ` parameter does not need to be specified.
138
157
139
158
## Timeout settings
140
159
@@ -294,5 +313,6 @@ follow the [development documentation].
294
313
[ future maintenance of `grafana_api` ] : https://github.com/m0nhawk/grafana_api/issues/88
295
314
[ grafana_api ] : https://github.com/m0nhawk/grafana_api
296
315
[ Grafana Admin API ] : https://grafana.com/docs/grafana/latest/http_api/admin/
316
+ [ X-Grafana-Org-Id header ] : https://grafana.com/docs/grafana/latest/developers/http_api/auth/#x-grafana-org-id-header
297
317
[ Grafana HTTP API reference ] : https://grafana.com/docs/grafana/latest/http_api/
298
318
[ LICENSE ] : https://github.com/panodata/grafana-client/blob/main/LICENSE
0 commit comments