pyrostorage.client#
The client submodule contains the core definition of the API client.
API Client#
- class pyrostorage.client.Client(api_url: str, credentials_login: str, credentials_password: str)[source]#
Client class to interact with the PyroNear API
- Parameters
api_url (str) – url of the pyronear API
credentials_login (str) – Login (e.g: username)
credentials_password (str) – Password (e.g: 123456 (don’t do this))
- create_annotation(media_id: int) Response [source]#
Create an annotation entry
- Example::
>>> from pyrostorage import client >>> api_client = client.Client("http://pyro-storage.herokuapp.com", "MY_LOGIN", "MY_PWD") >>> response = api_client.create_annotation(media_id=1)
- Parameters
media_id – the identifier of the media entry
- Returns
HTTP response containing the created annotation
- create_media(media_type: str = 'image') Response [source]#
Create a media entry
- Example::
>>> from pyrostorage import client >>> api_client = client.Client("http://pyro-storage.herokuapp.com", "MY_LOGIN", "MY_PWD") >>> response = api_client.create_media(media_type="image")
- Parameters
media_type – the type of media (‘image’, or ‘video’)
- Returns
HTTP response containing the created media
- get_annotation_url(annotation_id: int) Response [source]#
Get the image as a URL
- Example::
>>> from pyrostorage import client >>> api_client = client.Client("http://pyro-storage.herokuapp.com", "MY_LOGIN", "MY_PWD") >>> response = api_client.get_annotation_url(1)
- Parameters
annotation_id – the identifier of the annotation entry
- Returns
HTTP response containing the URL to the annotation content
- get_media_url(media_id: int) Response [source]#
Get the image as a URL
- Example::
>>> from pyrostorage import client >>> api_client = client.Client("http://pyro-storage.herokuapp.com", "MY_LOGIN", "MY_PWD") >>> response = api_client.get_media_url(1)
- Parameters
media_id – the identifier of the media entry
- Returns
HTTP response containing the URL to the media content
- upload_annotation(annotation_id: int, annotation_data: bytes) Response [source]#
Upload the annotation content
- Example::
>>> from pyrostorage import client >>> api_client = client.Client("http://pyro-storage.herokuapp.com", "MY_LOGIN", "MY_PWD") >>> with open("path/to/my/file.ext", "rb") as f: data = f.read() >>> response = api_client.upload_annotation(annotation_id=1, annotation_data=data)
- Parameters
annotation_id – ID of the associated annotation entry
annotation_data – byte data
- Returns
HTTP response containing the updated annotation
- upload_media(media_id: int, media_data: bytes) Response [source]#
Upload the media content
- Example::
>>> from pyrostorage import client >>> api_client = client.Client("http://pyro-storage.herokuapp.com", "MY_LOGIN", "MY_PWD") >>> with open("path/to/my/file.ext", "rb") as f: data = f.read() >>> response = api_client.upload_media(media_id=1, media_data=data)
- Parameters
media_id – ID of the associated media entry
media_data – byte data
- Returns
HTTP response containing the updated media