Skip to content

Commit 16a5244

Browse files
authored
docs: Fixes README badge and client documentation (#209)
* docs: Updated client documentation * docs: Updated README badges
1 parent 1f9bf7e commit 16a5244

File tree

4 files changed

+69
-89
lines changed

4 files changed

+69
-89
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<img alt="CI Status" src="https://img.shields.io/github/workflow/status/pyronear/pyro-api/builds?label=CI&logo=github&style=flat-square">
66
</a>
77
<a href="http://pyronear-api.herokuapp.com/redoc">
8-
<img src="https://img.shields.io/readthedocs/deezer-python.svg?logo=read-the-docs&style=flat-square" alt="Documentation Status">
8+
<img src="https://img.shields.io/github/workflow/status/pyronear/pyro-api/builds?label=docs&logo=read-the-docs&style=flat-square" alt="Documentation Status">
99
</a>
1010
<a href="https://codecov.io/gh/pyronear/pyro-api">
1111
<img src="https://img.shields.io/codecov/c/github/pyronear/pyro-api.svg?logo=codecov&style=flat-square" alt="Test coverage percentage">

client/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<a href="https://github.com/pyronear/pyro-api/actions?query=workflow%3Aclient">
55
<img alt="CI Status" src="https://img.shields.io/github/workflow/status/pyronear/pyro-api/client?label=CI&logo=github&style=flat-square">
66
</a>
7-
<a href="https://pyronear.org/pyro-api">
8-
<img src="https://img.shields.io/readthedocs/deezer-python.svg?logo=read-the-docs&style=flat-square" alt="Documentation Status">
7+
<a href="http://pyronear-api.herokuapp.com/redoc">
8+
<img alt="Documentation Status" src="https://img.shields.io/github/workflow/status/pyronear/pyro-api/docs?label=docs&logo=read-the-docs&style=flat-square">
99
</a>
1010
<a href="https://github.com/ambv/black">
1111
<img src="https://img.shields.io/badge/code%20style-black-000000.svg?style=flat-square" alt="black">
@@ -85,7 +85,7 @@ api_client.update_my_location(lat=1, lon=2, pitch=3)
8585

8686
## License
8787

88-
Distributed under the Apache 2.0 License. See `LICENSE` for more information.
88+
Distributed under the Apache 2.0 License. See [`LICENSE`](LICENSE) for more information.
8989

9090

9191

client/docs/source/conf.py

+1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
],
9898
"source_repository": "https://github.com/pyronear/pyro-api/",
9999
"source_branch": "master",
100+
"source_directory": "client/docs/source/",
100101
"sidebar_hide_name": True,
101102
}
102103

client/pyroclient/client.py

+64-85
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,9 @@ def _retrieve_token(self, login: str, password: str) -> str:
104104
def heartbeat(self) -> Response:
105105
"""Updates the last ping of the device
106106
107-
Example::
108-
>>> from pyroclient import client
109-
>>> api_client = client.Client("http://pyronear-api.herokuapp.com", "DEVICE_LOGIN", "MY_PWD")
110-
>>> response = api_client.heartbeat()
107+
>>> from pyroclient import client
108+
>>> api_client = client.Client("http://pyronear-api.herokuapp.com", "DEVICE_LOGIN", "MY_PWD")
109+
>>> response = api_client.heartbeat()
111110
112111
Returns:
113112
HTTP response containing the update device info
@@ -124,10 +123,9 @@ def update_my_location(
124123
) -> Response:
125124
"""Updates the location of the device
126125
127-
Example::
128-
>>> from pyroclient import client
129-
>>> api_client = client.Client("http://pyronear-api.herokuapp.com", "DEVICE_LOGIN", "MY_PWD")
130-
>>> response = api_client.update_my_location(lat=10., lon=-5.45)
126+
>>> from pyroclient import client
127+
>>> api_client = client.Client("http://pyronear-api.herokuapp.com", "DEVICE_LOGIN", "MY_PWD")
128+
>>> response = api_client.update_my_location(lat=10., lon=-5.45)
131129
132130
Returns:
133131
HTTP response containing the update device info
@@ -138,10 +136,9 @@ def update_my_location(
138136
def create_event(self, lat: float, lon: float) -> Response:
139137
"""Register an event (e.g wildfire).
140138
141-
Example::
142-
>>> from pyroclient import client
143-
>>> api_client = client.Client("http://pyronear-api.herokuapp.com", "MY_LOGIN", "MY_PWD")
144-
>>> response = api_client.create_event(lat=10., lon=-5.45)
139+
>>> from pyroclient import client
140+
>>> api_client = client.Client("http://pyronear-api.herokuapp.com", "MY_LOGIN", "MY_PWD")
141+
>>> response = api_client.create_event(lat=10., lon=-5.45)
145142
146143
Args:
147144
lat: the latitude of the event
@@ -158,10 +155,9 @@ def create_no_alert_site(
158155
) -> Response:
159156
"""Create a site that is not supposed to generate alerts.
160157
161-
Example::
162-
>>> from pyroclient import client
163-
>>> api_client = client.Client("http://pyronear-api.herokuapp.com", "MY_LOGIN", "MY_PWD")
164-
>>> response = api_client.create_no_alert_site(lat=10., lon=-5.45, name="farm", country="FR", geocode="01")
158+
>>> from pyroclient import client
159+
>>> api_client = client.Client("http://pyronear-api.herokuapp.com", "MY_LOGIN", "MY_PWD")
160+
>>> response = api_client.create_no_alert_site(lat=10., lon=-5.45, name="farm", country="FR", geocode="01")
165161
166162
Args:
167163
lat: the latitude of the site
@@ -189,10 +185,9 @@ def send_alert(
189185
) -> Response:
190186
"""Raise an alert to the API.
191187
192-
Example::
193-
>>> from pyroclient import client
194-
>>> api_client = client.Client("http://pyronear-api.herokuapp.com", "MY_LOGIN", "MY_PWD")
195-
>>> response = api_client.send_alert(lat=10., lon=-5.45, device_id=3, azimuth=2.)
188+
>>> from pyroclient import client
189+
>>> api_client = client.Client("http://pyronear-api.herokuapp.com", "MY_LOGIN", "MY_PWD")
190+
>>> response = api_client.send_alert(lat=10., lon=-5.45, device_id=3, azimuth=2.)
196191
197192
Args:
198193
lat: the latitude of the alert
@@ -223,10 +218,9 @@ def send_alert_from_device(
223218
) -> Response:
224219
"""Raise an alert to the API from a device (no need to specify device ID).
225220
226-
Example::
227-
>>> from pyroclient import client
228-
>>> api_client = client.Client("http://pyronear-api.herokuapp.com", "DEVICE_LOGIN", "MY_PWD")
229-
>>> response = api_client.send_alert_from_device(lat=10., lon=-5.45)
221+
>>> from pyroclient import client
222+
>>> api_client = client.Client("http://pyronear-api.herokuapp.com", "DEVICE_LOGIN", "MY_PWD")
223+
>>> response = api_client.send_alert_from_device(lat=10., lon=-5.45)
230224
231225
Args:
232226
lat: the latitude of the alert
@@ -250,10 +244,9 @@ def send_alert_from_device(
250244
def create_media(self, device_id: int) -> Response:
251245
"""Create a media entry
252246
253-
Example::
254-
>>> from pyroclient import client
255-
>>> api_client = client.Client("http://pyronear-api.herokuapp.com", "MY_LOGIN", "MY_PWD")
256-
>>> response = api_client.create_media(device_id=3)
247+
>>> from pyroclient import client
248+
>>> api_client = client.Client("http://pyronear-api.herokuapp.com", "MY_LOGIN", "MY_PWD")
249+
>>> response = api_client.create_media(device_id=3)
257250
258251
Args:
259252
device_id: ID of the device that created that media
@@ -267,10 +260,9 @@ def create_media(self, device_id: int) -> Response:
267260
def create_media_from_device(self):
268261
"""Create a media entry from a device (no need to specify device ID).
269262
270-
Example::
271-
>>> from pyroclient import client
272-
>>> api_client = client.Client("http://pyronear-api.herokuapp.com", "DEVICE_LOGIN", "MY_PWD")
273-
>>> response = api_client.create_media_from_device()
263+
>>> from pyroclient import client
264+
>>> api_client = client.Client("http://pyronear-api.herokuapp.com", "DEVICE_LOGIN", "MY_PWD")
265+
>>> response = api_client.create_media_from_device()
274266
275267
Returns:
276268
HTTP response containing the created media
@@ -281,11 +273,10 @@ def create_media_from_device(self):
281273
def upload_media(self, media_id: int, media_data: bytes) -> Response:
282274
"""Upload the media content
283275
284-
Example::
285-
>>> from pyroclient import client
286-
>>> api_client = client.Client("http://pyronear-api.herokuapp.com", "MY_LOGIN", "MY_PWD")
287-
>>> with open("path/to/my/file.ext", "rb") as f: data = f.read()
288-
>>> response = api_client.upload_media(media_id=1, media_data=data)
276+
>>> from pyroclient import client
277+
>>> api_client = client.Client("http://pyronear-api.herokuapp.com", "MY_LOGIN", "MY_PWD")
278+
>>> with open("path/to/my/file.ext", "rb") as f: data = f.read()
279+
>>> response = api_client.upload_media(media_id=1, media_data=data)
289280
290281
Args:
291282
media_id: ID of the associated media entry
@@ -305,10 +296,9 @@ def upload_media(self, media_id: int, media_data: bytes) -> Response:
305296
def get_my_devices(self) -> Response:
306297
"""Get the devices who are owned by the logged user
307298
308-
Example::
309-
>>> from pyroclient import client
310-
>>> api_client = client.Client("http://pyronear-api.herokuapp.com", "MY_LOGIN", "MY_PWD")
311-
>>> response = api_client.get_my_devices()
299+
>>> from pyroclient import client
300+
>>> api_client = client.Client("http://pyronear-api.herokuapp.com", "MY_LOGIN", "MY_PWD")
301+
>>> response = api_client.get_my_devices()
312302
313303
Returns:
314304
HTTP response containing the list of owned devices
@@ -318,10 +308,9 @@ def get_my_devices(self) -> Response:
318308
def get_sites(self) -> Response:
319309
"""Get all the existing sites in the DB
320310
321-
Example::
322-
>>> from pyroclient import client
323-
>>> api_client = client.Client("http://pyronear-api.herokuapp.com", "MY_LOGIN", "MY_PWD")
324-
>>> response = api_client.get_sites()
311+
>>> from pyroclient import client
312+
>>> api_client = client.Client("http://pyronear-api.herokuapp.com", "MY_LOGIN", "MY_PWD")
313+
>>> response = api_client.get_sites()
325314
326315
Returns:
327316
HTTP response containing the list of sites
@@ -331,10 +320,9 @@ def get_sites(self) -> Response:
331320
def get_all_alerts(self) -> Response:
332321
"""Get all the existing alerts in the DB
333322
334-
Example::
335-
>>> from pyroclient import client
336-
>>> api_client = client.Client("http://pyronear-api.herokuapp.com", "MY_LOGIN", "MY_PWD")
337-
>>> response = api_client.get_all_alerts()
323+
>>> from pyroclient import client
324+
>>> api_client = client.Client("http://pyronear-api.herokuapp.com", "MY_LOGIN", "MY_PWD")
325+
>>> response = api_client.get_all_alerts()
338326
339327
Returns:
340328
HTTP response containing the list of all alerts
@@ -344,10 +332,9 @@ def get_all_alerts(self) -> Response:
344332
def get_ongoing_alerts(self) -> Response:
345333
"""Get all the existing alerts in the DB that have the status 'start'
346334
347-
Example::
348-
>>> from pyroclient import client
349-
>>> api_client = client.Client("http://pyronear-api.herokuapp.com", "MY_LOGIN", "MY_PWD")
350-
>>> response = api_client.get_ongoing_alerts()
335+
>>> from pyroclient import client
336+
>>> api_client = client.Client("http://pyronear-api.herokuapp.com", "MY_LOGIN", "MY_PWD")
337+
>>> response = api_client.get_ongoing_alerts()
351338
352339
Returns:
353340
HTTP response containing the list of all ongoing alerts
@@ -358,10 +345,9 @@ def get_ongoing_alerts(self) -> Response:
358345
def get_unacknowledged_events(self) -> Response:
359346
"""Get all the existing events in the DB that have the field "is_acknowledged" set to `False`
360347
361-
Example::
362-
>>> from pyroclient import client
363-
>>> api_client = client.Client("http://pyronear-api.herokuapp.com", "MY_LOGIN", "MY_PWD")
364-
>>> response = api_client.get_unacknowledged_events()
348+
>>> from pyroclient import client
349+
>>> api_client = client.Client("http://pyronear-api.herokuapp.com", "MY_LOGIN", "MY_PWD")
350+
>>> response = api_client.get_unacknowledged_events()
365351
366352
Returns:
367353
HTTP response containing the list of all events that haven't been acknowledged
@@ -371,10 +357,9 @@ def get_unacknowledged_events(self) -> Response:
371357
def acknowledge_event(self, event_id: int) -> Response:
372358
"""Switch the `is_acknowledged` field value of the event to `True`
373359
374-
Example::
375-
>>> from pyroclient import client
376-
>>> api_client = client.Client("http://pyronear-api.herokuapp.com", "MY_LOGIN", "MY_PWD")
377-
>>> response = api_client.acknowledge_event(event_id=1)
360+
>>> from pyroclient import client
361+
>>> api_client = client.Client("http://pyronear-api.herokuapp.com", "MY_LOGIN", "MY_PWD")
362+
>>> response = api_client.acknowledge_event(event_id=1)
378363
379364
Args:
380365
event_id: ID of the associated event entry
@@ -388,10 +373,9 @@ def acknowledge_event(self, event_id: int) -> Response:
388373
def get_site_devices(self, site_id: int) -> Response:
389374
"""Fetch the devices that are installed on a specific site
390375
391-
Example::
392-
>>> from pyroclient import client
393-
>>> api_client = client.Client("http://pyronear-api.herokuapp.com", "MY_LOGIN", "MY_PWD")
394-
>>> response = api_client.get_site_devices(1)
376+
>>> from pyroclient import client
377+
>>> api_client = client.Client("http://pyronear-api.herokuapp.com", "MY_LOGIN", "MY_PWD")
378+
>>> response = api_client.get_site_devices(1)
395379
396380
Args:
397381
site_id: the identifier of the site
@@ -404,10 +388,9 @@ def get_site_devices(self, site_id: int) -> Response:
404388
def get_media_url(self, media_id: int) -> Response:
405389
"""Get the image as a URL
406390
407-
Example::
408-
>>> from pyroclient import client
409-
>>> api_client = client.Client("http://pyronear-api.herokuapp.com", "MY_LOGIN", "MY_PWD")
410-
>>> response = api_client.get_media_url(1)
391+
>>> from pyroclient import client
392+
>>> api_client = client.Client("http://pyronear-api.herokuapp.com", "MY_LOGIN", "MY_PWD")
393+
>>> response = api_client.get_media_url(1)
411394
412395
Args:
413396
media_id: the identifier of the media entry
@@ -421,10 +404,9 @@ def get_media_url(self, media_id: int) -> Response:
421404
def get_media_url_and_read(self, media_id: int) -> Response:
422405
"""Get the image as a url and read it
423406
424-
Example::
425-
>>> from pyroclient import client
426-
>>> api_client = client.Client("http://pyronear-api.herokuapp.com", "MY_LOGIN", "MY_PWD")
427-
>>> response = api_client.get_media_url_and_read(1)
407+
>>> from pyroclient import client
408+
>>> api_client = client.Client("http://pyronear-api.herokuapp.com", "MY_LOGIN", "MY_PWD")
409+
>>> response = api_client.get_media_url_and_read(1)
428410
429411
Args:
430412
media_id: the identifier of the media entry
@@ -438,10 +420,9 @@ def get_media_url_and_read(self, media_id: int) -> Response:
438420
def get_past_events(self) -> Response:
439421
"""Get all past events
440422
441-
Example::
442-
>>> from pyroclient import client
443-
>>> api_client = client.Client("http://pyronear-api.herokuapp.com", "MY_LOGIN", "MY_PWD")
444-
>>> response = api_client.get_past_events()
423+
>>> from pyroclient import client
424+
>>> api_client = client.Client("http://pyronear-api.herokuapp.com", "MY_LOGIN", "MY_PWD")
425+
>>> response = api_client.get_past_events()
445426
446427
Returns:
447428
HTTP response containing the list of past events
@@ -451,10 +432,9 @@ def get_past_events(self) -> Response:
451432
def get_my_device(self) -> Response:
452433
"""Get information about the current device
453434
454-
Example::
455-
>>> from pyroclient import client
456-
>>> api_client = client.Client("http://pyronear-api.herokuapp.com", "MY_LOGIN", "MY_PWD")
457-
>>> response = api_client.get_my_device()
435+
>>> from pyroclient import client
436+
>>> api_client = client.Client("http://pyronear-api.herokuapp.com", "MY_LOGIN", "MY_PWD")
437+
>>> response = api_client.get_my_device()
458438
459439
Returns:
460440
HTTP response containing the device information
@@ -464,10 +444,9 @@ def get_my_device(self) -> Response:
464444
def update_my_hash(self, software_hash: str) -> Response:
465445
"""Updates the software hash of the current device
466446
467-
Example::
468-
>>> from pyroclient import client
469-
>>> api_client = client.Client("http://pyronear-api.herokuapp.com", "MY_LOGIN", "MY_PWD")
470-
>>> response = api_client.update_my_hash()
447+
>>> from pyroclient import client
448+
>>> api_client = client.Client("http://pyronear-api.herokuapp.com", "MY_LOGIN", "MY_PWD")
449+
>>> response = api_client.update_my_hash()
471450
472451
Returns:
473452
HTTP response containing the updated device information

0 commit comments

Comments
 (0)