Skip to content

Commit a630b7c

Browse files
committed
Documentation: Update README, add a dedicated "Configuration Settings"
1 parent 1925f8e commit a630b7c

File tree

1 file changed

+32
-25
lines changed

1 file changed

+32
-25
lines changed

README.md

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ A client library for accessing the Grafana HTTP API, written in Python.
2222

2323
Install the package from PyPI.
2424
```
25-
pip install grafana-client --upgrade
25+
pip install --upgrade grafana-client
2626
```
2727

2828

@@ -33,6 +33,7 @@ pip install grafana-client --upgrade
3333
This section gives you an idea about how to use the API on behalf of a few
3434
samples.
3535

36+
#### Synchronous
3637
```python
3738
from grafana_client import GrafanaApi
3839

@@ -73,16 +74,19 @@ grafana.organization.create_organization(
7374
organization={"name": "new_organization"})
7475
```
7576

76-
Or using asynchronous code... the interfaces are identical except for the fact that you will handle coroutines (async/await).
77+
#### Asynchronous
78+
79+
The asynchronous interfaces are identical, except for the fact that you will
80+
need to properly handle coroutines (async/await).
7781

7882
```python
79-
from grafana_client import AsyncGrafanaApi
8083
import asyncio
84+
from grafana_client import AsyncGrafanaApi
8185

8286
async def main():
8387
# Connect to Grafana API endpoint using the `GrafanaApi` class
8488
grafana = AsyncGrafanaApi.from_url("https://username:[email protected]/grafana/")
85-
89+
8690
# Create user
8791
user = await grafana.admin.create_user({
8892
"name": "User",
@@ -91,7 +95,7 @@ async def main():
9195
"password": "userpassword",
9296
"OrgId": 1,
9397
})
94-
98+
9599
# Change user password
96100
user = await grafana.admin.change_user_password(2, "newpassword")
97101

@@ -107,7 +111,9 @@ Feel free to use them as blueprints for your own programs. If you think your
107111
exercises could be useful for others, don't hesitate to share them back.
108112

109113

110-
## Authentication
114+
## Configuration Settings
115+
116+
### Authentication
111117

112118
There are several ways to authenticate to the Grafana HTTP API.
113119

@@ -160,7 +166,18 @@ grafana = GrafanaApi.from_env()
160166
Please note that, on top of the specific examples above, the object obtained by
161167
`credential` can be an arbitrary `niquests.auth.AuthBase` instance.
162168

163-
## Selecting Organizations
169+
### DNS Resolver
170+
171+
`niquests` support using a custom DNS resolver, like but not limited, DNS-over-HTTPS, and DNS-over-QUIC.
172+
You will have to set `NIQUESTS_DNS_URL` environment variable. For example:
173+
```
174+
export NIQUESTS_DNS_URL="doh+cloudflare://"
175+
```
176+
177+
See the [documentation](https://niquests.readthedocs.io/en/latest/user/quickstart.html#set-dns-via-environment) to learn
178+
more about accepted URL parameters and protocols.
179+
180+
### Grafana Organization
164181

165182
If the Grafana API is authenticated as a user (for example, with HTTP Basic Authentication),
166183
it will use the user's current organization context.
@@ -180,16 +197,7 @@ grafana = GrafanaApi(..., organization_id=1)
180197

181198
API Tokens are bound to a single organization, so the `organization_id` parameter does not need to be specified.
182199

183-
## Timeout settings
184-
185-
The default timeout value is five seconds, used for both connect and read timeout.
186-
187-
The constructors of `GrafanaApi` and `GrafanaClient`, as well as the factory methods
188-
`from_url` and `from_env` accept the `timeout` argument, which can be obtained as a
189-
scalar `float` value, or as a tuple of `(<read timeout>, <connect timeout>)`.
190-
191-
192-
## Proxy
200+
### HTTP Proxy
193201

194202
The underlying `niquests` library honors the `HTTP_PROXY` and `HTTPS_PROXY`
195203
environment variables. Setting them before invoking an application using
@@ -199,16 +207,15 @@ export HTTP_PROXY=10.10.1.10:3128
199207
export HTTPS_PROXY=10.10.1.11:1080
200208
```
201209

202-
## DNS Resolver
210+
### TCP Timeout
211+
212+
The default timeout value is five seconds, used for both connect and read timeout.
213+
214+
The constructors of `GrafanaApi` and `GrafanaClient`, as well as the factory methods
215+
`from_url` and `from_env` accept the `timeout` argument, which can be obtained as a
216+
scalar `float` value, or as a tuple of `(<read timeout>, <connect timeout>)`.
203217

204-
`niquests` support using a custom DNS resolver, like but not limited, DNS-over-HTTPS, and DNS-over-QUIC.
205-
You will have to set `NIQUESTS_DNS_URL` environment variable. For example:
206-
```
207-
export NIQUESTS_DNS_URL="doh+cloudflare://"
208-
```
209218

210-
See the [documentation](https://niquests.readthedocs.io/en/latest/user/quickstart.html#set-dns-via-environment) to learn
211-
more about accepted URL parameters and protocols.
212219

213220
## Details
214221

0 commit comments

Comments
 (0)