Skip to content

Commit

Permalink
improved docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
Mopsgeschwindigkeit committed Nov 11, 2023
1 parent ebf4c58 commit 811d0ad
Show file tree
Hide file tree
Showing 15 changed files with 197 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/sxapi/integrationV2/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def get_usages(self, **kwargs):
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 Down
6 changes: 3 additions & 3 deletions src/sxapi/integrationV2/organisations.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,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 @@ -140,7 +140,7 @@ def get_animals(self, organisation_id, **kwargs):
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 Down Expand Up @@ -279,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 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
34 changes: 31 additions & 3 deletions src/sxapi/publicV2/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ def __init__(self, api=None):
def get_data_animals(self, animal_id, metrics, from_date, to_date, **kwargs):
"""Query sensordata for an animal.
https://api.smaxtec.com/api/v2/data/animals/{animal_id}.json
Args:
animal_id (str): ID of the animal
metrics (list(str)): List of metrics to query
Expand All @@ -35,14 +37,16 @@ def get_data_animals(self, animal_id, metrics, from_date, to_date, **kwargs):
def get_metrics_animals(self, animal_id, **kwargs):
"""List available metrics for an animal.
https://api.smaxtec.com/api/v2/data/animals/{animal_id}/metrics
Args:
animal_id (str): ID of the animal
**kwargs: Optional parameters of the API call.
Find supported parameters under
https://api.smaxtec.com/api/v2/
Returns:
dict: Response from the API. List of available metrics on success,
list[dict]: Response from the API. List of available metrics on success,
error message else.
"""
Expand All @@ -56,6 +60,8 @@ def get_metrics_animals(self, animal_id, **kwargs):
def get_data_devices(self, device_id, metrics, from_date, to_date, **kwargs):
"""Query sensordata for a device.
https://api.smaxtec.com/api/v2/data/devices/{device_id}.json
Args:
device_id (str): ID of the device
metrics (list(str)): List of metrics to query
Expand All @@ -81,14 +87,16 @@ def get_data_devices(self, device_id, metrics, from_date, to_date, **kwargs):
def get_metrics_devices(self, device_id, **kwargs):
"""List available metrics for a device.
https://api.smaxtec.com/api/v2/data/devices/{device_id}/metrics
Args:
device_id (str): ID of the device
**kwargs: Optional parameters of the API call.
Find supported parameters under
https://api.smaxtec.com/api/v2/
Returns:
dict: Response from the API. List of available metrics on success,
list[dict]: Response from the API. List of available metrics on success,
error message else.
"""
Expand All @@ -104,6 +112,8 @@ def get_download_animal_data(
):
"""Download sensordata for animals.
https://api.smaxtec.com/api/v2/data/download_animal_data
Args:
animal_ids (list(str)): List of animal IDs
metrics (list(str)): List of metrics to query
Expand Down Expand Up @@ -136,6 +146,8 @@ def get_download_device_data(
):
"""Download sensordata for devices.
https://api.smaxtec.com/api/v2/data/download_device_data
Args:
device_ids (list(str)): List of device IDs
metrics (list(str)): List of metrics to query
Expand Down Expand Up @@ -166,6 +178,8 @@ def get_download_device_data(
def get_download_group_data(self, group_ids, metrics, from_date, to_date, **kwargs):
"""Download sensordata for groups.
https://api.smaxtec.com/api/v2/data/download_group_data
Args:
group_ids (list(str)): List of group IDs
metrics (list(str)): List of metrics to query
Expand Down Expand Up @@ -197,6 +211,8 @@ def post_downloads_excel_report(self, from_date, to_date, **kwargs):
"""Generates an Excel report and sends an email
containing a download link for the Excel report to the user.
https://api.smaxtec.com/api/v2/data/downloads/generate_excel_report
Args:
from_date (str): Query from date
to_date (str): Query end date
Expand All @@ -220,6 +236,8 @@ def post_downloads_messages_excel_report(self, from_date, to_date, **kwargs):
"""Generates an Excel report and sends an email
containing a download link for the Excel report to the user.
https://api.smaxtec.com/api/v2/data/downloads/generate_messages_excel_report
Args:
from_date (str): Query from date
to_date (str): Query end date
Expand All @@ -245,6 +263,8 @@ def post_downloads_organisation_messages_excel_report(
"""Generates an Excel report and sends an email
containing a download link for the Excel report to the user.
https://api.smaxtec.com/api/v2/data/downloads/generate_organisation_messages_excel_report
Args:
organisation_id (str): ID of organisation the report should be created for
from_date (str): Query from date
Expand Down Expand Up @@ -274,6 +294,8 @@ def post_downloads_organisation_messages_excel_report(
def get_downloads(self, download_id, **kwargs):
"""Download a generated Excel report.
https://api.smaxtec.com/api/v2/data/downloads/{download_id}
Args:
download_id (str): ID of the download
**kwargs: Optional parameters of the API call.
Expand All @@ -295,6 +317,8 @@ def get_data_feedrations(
):
"""Query feedration data.
https://api.smaxtec.com/api/v2/data/feedrations/{feedration_id}.json
Args:
feedration_id (str): ID of the feedration group
metrics (list(str)): List of metrics to query
Expand All @@ -320,6 +344,8 @@ def get_data_feedrations(
def get_data_groups(self, group_id, metrics, from_date, to_date, **kwargs):
"""Query group data.
https://api.smaxtec.com/api/v2/data/groups/{group_id}.json
Args:
group_id (str): ID of the group
metrics (list(str)): List of metrics to query
Expand All @@ -343,13 +369,15 @@ def get_data_groups(self, group_id, metrics, from_date, to_date, **kwargs):
def get_metrics_groups(self, group_id, **kwargs):
"""List available metrics for a group.
https://api.smaxtec.com/api/v2/data/groups/{group_id}/metrics
Args:
group_id (str): ID of the group
**kwargs: Optional parameters of the API call.
Find supported parameters under
https://api.smaxtec.com/api/v2/
Returns:
dict: Response from the API. List of available metrics on success,
list[dict]: Response from the API. List of available metrics on success,
error message else.
"""
params = {}
Expand Down
15 changes: 9 additions & 6 deletions src/sxapi/publicV2/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ def __init__(self, api=None):
self.path_suffix = "/devices"

def get_check_activatable(self, device_id, activation_code, **kwargs):
"""
Check if a device can be activated with the given activation code.
"""Check if a device can be activated with the given activation code.
https://api.smaxtec.com/api/v2/devices/{device_id}/check_activatable
Args:
device_id (str): ID of the device check if activation is possible
Expand All @@ -34,8 +35,9 @@ def get_check_activatable(self, device_id, activation_code, **kwargs):
def put_move(
self, device_id, organisation_id, target_organisation_id, archive, **kwargs
):
"""
Move a device to another organisation.
"""Move a device to another organisation.
https://api.smaxtec.com/api/v2/data/{device_id}/move
Args:
device_id (str): ID of the device to be moved
Expand Down Expand Up @@ -64,8 +66,9 @@ def put_move(
return self.api.put(url_suffix, json=params)

def put_update_name(self, device_id, name, **kwargs):
"""
Update the name of a device.
"""Update the name of a device.
https://api.smaxtec.com/api/v2/data/{device_id}/update_name
Args:
device_id (str): ID of the device to be moved
Expand Down
10 changes: 8 additions & 2 deletions src/sxapi/publicV2/events.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, organisation_id, **kwargs):
"""Get all events of an organisation.
https://api.smaxtec.com/api/v2/events
Args:
organisation_id (str): ID of the organisation the events
should be retrieved for
Expand All @@ -35,6 +37,8 @@ def get(self, organisation_id, **kwargs):
def get_by_id(self, event_id, **kwargs):
"""Get one event by ID.
https://api.smaxtec.com/api/v2/events/by_id
Args:
event_id (str): ID of the desired event
**kwargs: Optional parameters of the API call.
Expand All @@ -59,13 +63,15 @@ def get_categories(self, **kwargs):
If no user id or organisation id in the parameter
a Bad Request Error will be returned!
https://api.smaxtec.com/api/v2/events/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 event categories on success,
list[dict]: Response of API call. List of event categories on success,
error message else.
"""
Expand All @@ -74,4 +80,4 @@ def get_categories(self, **kwargs):
params[k] = v

url_suffix = self.path_suffix + "/categories"
return self.api.get(url_suffix, json=params)
return self.api.get(url_suffix, json=params)
8 changes: 8 additions & 0 deletions src/sxapi/publicV2/feedrations.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, organisation_id, **kwargs):
"""Creates a new feedration.
https://api.smaxtec.com/api/v2/feedrations
Args:
name (str): Name of the feedration to be created
organisation_id (str): ID of the organisation the feedration
Expand All @@ -37,6 +39,8 @@ def post(self, name, organisation_id, **kwargs):
def put(self, feedration_id, name, organisation_id, **kwargs):
"""Updates an existing feedration.
https://api.smaxtec.com/api/v2/feedrations/{feedration_id}
Args:
feedration_id (str): ID of the feedration which should be updated.
name (str): Name of the feedration to be updated
Expand Down Expand Up @@ -64,6 +68,8 @@ def put(self, feedration_id, name, organisation_id, **kwargs):
def get(self, feedration_id, **kwargs):
"""Get one feedration.
https://api.smaxtec.com/api/v2/feedrations/{feedration_id}
Args:
feedration_id (str): ID of the desired feedration
**kwargs: Optional parameters of the API call.
Expand All @@ -85,6 +91,8 @@ def get(self, feedration_id, **kwargs):
def delete(self, feedration_id, **kwargs):
"""Deletes a feedration.
https://api.smaxtec.com/api/v2/feedrations/{feedration_id}
Args:
feedration_id (str): ID of the feedration which should be deleted.
**kwargs: Optional parameters of the API call.
Expand Down
Loading

0 comments on commit 811d0ad

Please sign in to comment.