Skip to content

Commit

Permalink
Improve docstrings (#47)
Browse files Browse the repository at this point in the history
* added urls to docstrigs integration api

* improved docstrings
  • Loading branch information
Mopsgeschwindigkeit authored Nov 11, 2023
1 parent a5cb9c3 commit 6df6394
Show file tree
Hide file tree
Showing 17 changed files with 247 additions and 31 deletions.
8 changes: 7 additions & 1 deletion src/sxapi/integrationV2/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ def __init__(self, api=None):
def get_usages(self, **kwargs):
"""Get usages of provided account numbers.
https://api.smaxtec.com/integration/v2/accounts/usages
Args:
**kwargs: Optional parameters of the API call.
Find supported parameters under
https://api.smaxtec.com/integration/v2/
Returns:
dict: Response of API call. List of usages on success,
list[dict]: Response of API call. List of usages on success,
error message else.
"""
Expand All @@ -41,6 +43,8 @@ def put(
):
"""Update an account.
https://api.smaxtec.com/integration/v2/accounts/{account_nr}
Args:
account_nr (str): Account number of the account
account_name (str): Name of the account
Expand Down Expand Up @@ -74,6 +78,8 @@ def put(
def put_organisation(self, account_nr, organisation_id, **kwargs):
"""Add an account to an organisation.
https://api.smaxtec.com/integration/v2/accounts/{account_nr}/organisation/{organisation_id}
Args:
account_nr (str): Account number of the account
organisation_id (str): Organisation ID of the organisation
Expand Down
42 changes: 39 additions & 3 deletions src/sxapi/integrationV2/organisations.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ def __init__(self, api=None):
def post(self, name, timezone, **kwargs):
"""Create an organisation.
https://api.smaxtec.com/integration/v2/organisations
Args:
name (str): Name of the organisation
timezone (str): Timezone of the organisation
Expand All @@ -33,6 +35,8 @@ def post(self, name, timezone, **kwargs):
def get(self, **kwargs):
"""Get all organisation the user has access to.
https://api.smaxtec.com/integration/v2/organisations
Args:
**kwargs: Optional parameters of the API call.
Find supported parameters under
Expand All @@ -54,6 +58,8 @@ def get(self, **kwargs):
def get_odoo_organisations(self, **kwargs):
"""Get all odoo organisations the user has access to.
https://api.smaxtec.com/integration/v2/organisations/odoo_organisations
Args:
**kwargs: Optional parameters of the API call.
Find supported parameters under
Expand All @@ -76,6 +82,8 @@ def get_odoo_organisations(self, **kwargs):
def get_animal_ids(self, organisation_id, **kwargs):
"""Get all animal official_ids of an organisation.
https://api.smaxtec.com/integration/v2/organisations/{organisation_id}/animal_ids
Args:
organisation_id (str): Organisation ID of the organisation
**kwargs: Optional parameters of the API call.
Expand All @@ -98,6 +106,8 @@ def get_animal_ids(self, organisation_id, **kwargs):
def put_animals(self, organisation_id, body, **kwargs):
"""Create/Update animals of an organisation.
https://api.smaxtec.com/integration/v2/organisations/{organisation_id}/animals
Args:
organisation_id (str): Organisation ID of the organisation
body (:obj:`list` of :obj:`dict`): List of animals to create/update
Expand All @@ -106,7 +116,7 @@ def put_animals(self, organisation_id, body, **kwargs):
https://api.smaxtec.com/integration/v2/
Returns:
dict: Response of API call. List of animal ids on success,
list[dict]: Response of API call. List of animal ids on success,
error message else.
"""
Expand All @@ -121,14 +131,16 @@ def put_animals(self, organisation_id, body, **kwargs):
def get_animals(self, organisation_id, **kwargs):
"""Get all animals of an organisation.
https://api.smaxtec.com/integration/v2/organisations/{organisation_id}/animals
Args:
organisation_id (str): Organisation ID of the organisation
**kwargs: Optional parameters of the API call.
Find supported parameters under
https://api.smaxtec.com/integration/v2/
Returns:
dict: Response of API call. List of animals on success,
list[dict]: Response of API call. List of animals on success,
error message else.
"""
Expand All @@ -143,6 +155,8 @@ def get_animals(self, organisation_id, **kwargs):
def put_animals_by_official_id(self, organisation_id, official_id, **kwargs):
"""Create/Update an animal of an organisation by official_id.
https://api.smaxtec.com/integration/v2/organisations/{organisation_id}/animals/{official_id}
Args:
organisation_id (str): Organisation ID of the organisation
official_id (str): Official ID of the animal
Expand All @@ -165,6 +179,8 @@ def put_animals_by_official_id(self, organisation_id, official_id, **kwargs):
def get_animals_by_official_id(self, organisation_id, official_id, **kwargs):
"""Get an animal of an organisation by official_id.
https://api.smaxtec.com/integration/v2/organisations/{organisation_id}/animals/{official_id}
Args:
organisation_id (str): Organisation ID of the organisation
official_id (str): Official ID of the animal
Expand All @@ -190,6 +206,8 @@ def get_animals_data_by_official_id(
):
"""Get sensordata of an animal by official_id.
https://api.smaxtec.com/integration/v2/organisations/{organisation_id}/animals/{official_id}/data.json
Args:
organisation_id (str): Organisation ID of the organisation
official_id (str): Official ID of the animal
Expand Down Expand Up @@ -224,6 +242,8 @@ def put_animals_events_by_official_id(
):
"""Create/Update events of an animal by official_id.
https://api.smaxtec.com/integration/v2/organisations/{organisation_id}/animals/{official_id}/events
Args:
organisation_id (str): Organisation ID of the organisation
official_id (str): Official ID of the animal
Expand All @@ -249,6 +269,8 @@ def put_animals_events_by_official_id(
def get_animals_events_by_official_id(self, organisation_id, official_id, **kwargs):
"""Get events of an animal by official_id.
https://api.smaxtec.com/integration/v2/organisations/{organisation_id}/animals/{official_id}/events
Args:
organisation_id (str): Organisation ID of the organisation
official_id (str): Official ID of the animal
Expand All @@ -257,7 +279,7 @@ def get_animals_events_by_official_id(self, organisation_id, official_id, **kwar
https://api.smaxtec.com/integration/v2/
Returns:
dict: Response of API call. List of animal events on success,
list[dict]: Response of API call. List of animal events on success,
error message else.
"""
Expand All @@ -276,6 +298,8 @@ def get_animals_metrics_by_official_id(
):
"""Get a list of metrics available for animal.
https://api.smaxtec.com/integration/v2/organisations/{organisation_id}/animals/{official_id}/metrics
Args:
organisation_id (str): Organisation ID of the organisation
official_id (str): Official ID of the animal
Expand All @@ -300,6 +324,8 @@ def get_animals_metrics_by_official_id(
def put_animals_events(self, organisation_id, events, **kwargs):
"""Create/Update events of an organisation.
https://api.smaxtec.com/integration/v2/organisations/{organisation_id}/animals_events
Args:
organisation_id (str): Organisation ID of the organisation
events (:obj:`list` of :obj:`dict`): List of events to create/update
Expand All @@ -322,6 +348,8 @@ def put_animals_events(self, organisation_id, events, **kwargs):
def get_devices(self, organisation_id, **kwargs):
"""Get all devices of an organisation.
https://api.smaxtec.com/integration/v2/organisations/{organisation_id}/devices
Args:
organisation_id (str): ID of the organisation
**kwargs: Optional parameters of the API call.
Expand All @@ -346,6 +374,8 @@ def get_devices_data(
):
"""Get sensordata of a device.
https://api.smaxtec.com/integration/v2/organisations/{organisation_id}/devices/{device_id}/data.json
Args:
organisation_id (str): ID of the organisation
device_id (str): ID of the device
Expand Down Expand Up @@ -377,6 +407,8 @@ def get_devices_data(
def get_devices_readouts_latest(self, organisation_id, device_id, **kwargs):
"""Get latest readout of a device.
https://api.smaxtec.com/integration/v2/organisations/{organisation_id}/devices/{device_id}/readouts/latest
Args:
organisation_id (str): ID of the organisation
device_id (str): ID of the device
Expand All @@ -402,6 +434,8 @@ def get_devices_readouts_latest(self, organisation_id, device_id, **kwargs):
def get_events(self, organisation_id, **kwargs):
"""Get all events of an organisation.
https://api.smaxtec.com/integration/v2/organisations/{organisation_id}/events
Args:
organisation_id (str): ID of the organisation
**kwargs: Optional parameters of the API call.
Expand All @@ -424,6 +458,8 @@ def get_events(self, organisation_id, **kwargs):
def get_simple_animals(self, organisation_id, **kwargs):
"""Get all animals of an organisation.
https://api.smaxtec.com/integration/v2/organisations/{organisation_id}/simple_animals
Args:
organisation_id (str): ID of the organisation
**kwargs: Optional parameters of the API call.
Expand Down
4 changes: 4 additions & 0 deletions src/sxapi/integrationV2/tranlations.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ def __init__(self, api=None):
def get_events(self, language, **kwargs):
"""Get translations for events.
https://api.smaxtec.com/integration/v2/translations/{language}/events
Args:
language (str): Language of the events to be returned
**kwargs: Optional parameters of the API call.
Expand All @@ -33,6 +35,8 @@ def get_events(self, language, **kwargs):
def get_event_types(self, language, event_type, **kwargs):
"""Get translations for event types.
https://api.smaxtec.com/integration/v2/translations/{language}/events/{event_type}
Args:
language (str): Language of the event types to be returned
event_type (str): Type of the event types to be returned
Expand Down
4 changes: 4 additions & 0 deletions src/sxapi/integrationV2/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ def __init__(self, api=None):
def get(self, **kwargs):
"""Grant access to demo farm
https://api.smaxtec.com/integration/v2/users
Args:
**kwargs: Optional parameters of the API call.
Find supported parameters under
Expand All @@ -31,6 +33,8 @@ def get(self, **kwargs):
def post_session_token(self, user, password, **kwargs):
"""Creates a new session token.
https://api.smaxtec.com/integration/v2/users/session_token
Args:
user (str): Email of the user to be logged in
password (str): Password of the user to be logged in
Expand Down
13 changes: 12 additions & 1 deletion src/sxapi/publicV2/alarms.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ def __init__(self, api=None):
def post(self, organisation_id, title, **kwargs):
"""Creates a new alarm.
https://api.smaxtec.com/api/v2/alarms
Args:
organisation_id (str): ID of organisation the alarm should be created for
title (str): Title of the alarm
Expand All @@ -37,13 +39,16 @@ def get_categories(self, **kwargs):
If no user or organisation is given, this
function return a BadRequestError
https://api.smaxtec.com/api/v2/alarms/categories
Args:
**kwargs: Optional parameters of the API call.
Find supported parameters under
https://api.smaxtec.com/api/v2/
Returns:
dict: Response of API call. List of alarms on success, error message else.
list[dict]: Response of API call. List of alarms on success,
error message else.
"""
params = {}
Expand All @@ -57,6 +62,8 @@ def get_categories(self, **kwargs):
def put(self, alarm_id, organisation_id, **kwargs):
"""Updates an existing alarm.
https://api.smaxtec.com/api/v2/alarms/{alarm_id}
Args:
alarm_id (str): ID of the alarm which should be updated.
organisation_id (str): ID of organisation the alarm should be updated for
Expand All @@ -80,6 +87,8 @@ def put(self, alarm_id, organisation_id, **kwargs):
def get(self, alarm_id, **kwargs):
"""Get one alarm.
https://api.smaxtec.com/api/v2/alarms/{alarm_id}
Args:
alarm_id (str): ID of the desired alarm
**kwargs: Optional parameters of the API call.
Expand All @@ -101,6 +110,8 @@ def get(self, alarm_id, **kwargs):
def delete(self, alarm_id, **kwargs):
"""Delete one alarm.
https://api.smaxtec.com/api/v2/alarms/{alarm_id}
Args:
alarm_id (str): ID of the alarm to delete
**kwargs: Optional parameters of the API call.
Expand Down
8 changes: 8 additions & 0 deletions src/sxapi/publicV2/animalgroups.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ def __init__(self, api=None):
def post(self, name, location, organisation_id, **kwargs):
"""Create a new animal group.
https://api.smaxtec.com/api/v2/animalgroups
Args:
name (str): Name of the animal group
location (str): Location of the animal group
Expand Down Expand Up @@ -39,6 +41,8 @@ def post(self, name, location, organisation_id, **kwargs):
def put(self, group_id, name, location, organisation_id, **kwargs):
"""Update an animal group.
https://api.smaxtec.com/api/v2/animalgroups/{group_id}
Args:
group_id (str): ID of the animal group
name (str): Name of the animal group
Expand Down Expand Up @@ -69,6 +73,8 @@ def put(self, group_id, name, location, organisation_id, **kwargs):
def get(self, group_id, **kwargs):
"""Get one animal group by ID.
https://api.smaxtec.com/api/v2/animalgroups/{group_id}
Args:
group_id (str): ID of the desired animal group
**kwargs: Optional parameters of the API call.
Expand All @@ -90,6 +96,8 @@ def get(self, group_id, **kwargs):
def delete(self, group_id, **kwargs):
"""Delete an animal group.
https://api.smaxtec.com/api/v2/animalgroups/{group_id}
Args:
group_id (str): ID of the animal group
**kwargs: Optional parameters of the API call.
Expand Down
Loading

0 comments on commit 6df6394

Please sign in to comment.