From 6df63948bad7282422b806070560a32e987874cb Mon Sep 17 00:00:00 2001 From: Marco Moser <63156265+Mopsgeschwindigkeit@users.noreply.github.com> Date: Sat, 11 Nov 2023 10:13:30 +0000 Subject: [PATCH] Improve docstrings (#47) * added urls to docstrigs integration api * improved docstrings --- src/sxapi/integrationV2/accounts.py | 8 ++++- src/sxapi/integrationV2/organisations.py | 42 ++++++++++++++++++++++-- src/sxapi/integrationV2/tranlations.py | 4 +++ src/sxapi/integrationV2/users.py | 4 +++ src/sxapi/publicV2/alarms.py | 13 +++++++- src/sxapi/publicV2/animalgroups.py | 8 +++++ src/sxapi/publicV2/data.py | 34 +++++++++++++++++-- src/sxapi/publicV2/devices.py | 15 +++++---- src/sxapi/publicV2/events.py | 10 ++++-- src/sxapi/publicV2/feedrations.py | 8 +++++ src/sxapi/publicV2/groups.py | 15 +++++---- src/sxapi/publicV2/notes.py | 23 +++++++++++-- src/sxapi/publicV2/observation_groups.py | 18 ++++++++++ src/sxapi/publicV2/sensordata.py | 16 +++++++-- src/sxapi/publicV2/shares.py | 10 +++++- src/sxapi/publicV2/todos.py | 12 +++++++ src/sxapi/publicV2/users.py | 38 +++++++++++++++++++-- 17 files changed, 247 insertions(+), 31 deletions(-) diff --git a/src/sxapi/integrationV2/accounts.py b/src/sxapi/integrationV2/accounts.py index ea98f62..fc49b8f 100644 --- a/src/sxapi/integrationV2/accounts.py +++ b/src/sxapi/integrationV2/accounts.py @@ -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. """ @@ -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 @@ -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 diff --git a/src/sxapi/integrationV2/organisations.py b/src/sxapi/integrationV2/organisations.py index feea78d..1e1e34e 100644 --- a/src/sxapi/integrationV2/organisations.py +++ b/src/sxapi/integrationV2/organisations.py @@ -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 @@ -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 @@ -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 @@ -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. @@ -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 @@ -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. """ @@ -121,6 +131,8 @@ 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. @@ -128,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. """ @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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. """ @@ -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 @@ -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 @@ -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. @@ -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 @@ -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 @@ -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. @@ -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. diff --git a/src/sxapi/integrationV2/tranlations.py b/src/sxapi/integrationV2/tranlations.py index 70f79ab..432aa1c 100644 --- a/src/sxapi/integrationV2/tranlations.py +++ b/src/sxapi/integrationV2/tranlations.py @@ -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. @@ -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 diff --git a/src/sxapi/integrationV2/users.py b/src/sxapi/integrationV2/users.py index 139f176..95bf231 100644 --- a/src/sxapi/integrationV2/users.py +++ b/src/sxapi/integrationV2/users.py @@ -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 @@ -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 diff --git a/src/sxapi/publicV2/alarms.py b/src/sxapi/publicV2/alarms.py index e911f6e..a7dbf71 100644 --- a/src/sxapi/publicV2/alarms.py +++ b/src/sxapi/publicV2/alarms.py @@ -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 @@ -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 = {} @@ -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 @@ -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. @@ -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. diff --git a/src/sxapi/publicV2/animalgroups.py b/src/sxapi/publicV2/animalgroups.py index 7352270..4f173bd 100644 --- a/src/sxapi/publicV2/animalgroups.py +++ b/src/sxapi/publicV2/animalgroups.py @@ -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 @@ -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 @@ -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. @@ -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. diff --git a/src/sxapi/publicV2/data.py b/src/sxapi/publicV2/data.py index 6b62ee5..3993207 100644 --- a/src/sxapi/publicV2/data.py +++ b/src/sxapi/publicV2/data.py @@ -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 @@ -35,6 +37,8 @@ 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. @@ -42,7 +46,7 @@ def get_metrics_animals(self, animal_id, **kwargs): 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. """ @@ -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 @@ -81,6 +87,8 @@ 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. @@ -88,7 +96,7 @@ def get_metrics_devices(self, device_id, **kwargs): 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. """ @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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. @@ -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 @@ -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 @@ -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 = {} diff --git a/src/sxapi/publicV2/devices.py b/src/sxapi/publicV2/devices.py index 00bdc48..51935ea 100644 --- a/src/sxapi/publicV2/devices.py +++ b/src/sxapi/publicV2/devices.py @@ -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 @@ -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 @@ -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 diff --git a/src/sxapi/publicV2/events.py b/src/sxapi/publicV2/events.py index 430ec6e..1059792 100644 --- a/src/sxapi/publicV2/events.py +++ b/src/sxapi/publicV2/events.py @@ -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 @@ -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. @@ -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. """ @@ -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) \ No newline at end of file + return self.api.get(url_suffix, json=params) diff --git a/src/sxapi/publicV2/feedrations.py b/src/sxapi/publicV2/feedrations.py index 963ed00..0036428 100644 --- a/src/sxapi/publicV2/feedrations.py +++ b/src/sxapi/publicV2/feedrations.py @@ -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 @@ -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 @@ -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. @@ -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. diff --git a/src/sxapi/publicV2/groups.py b/src/sxapi/publicV2/groups.py index 6498405..cf79884 100644 --- a/src/sxapi/publicV2/groups.py +++ b/src/sxapi/publicV2/groups.py @@ -9,8 +9,9 @@ def __init__(self, api=None): self.path_suffix = "/groups" def put_actions(self, group_id, **kwargs): - """ - Add an action to a group. + """Add an action to a group. + + https://api.smaxtec.com/api/v2/groups/{group_id}/actions Args: group_id (str): ID of the group which should be updated. @@ -30,8 +31,9 @@ def put_actions(self, group_id, **kwargs): self.api.put(url_suffix, json=params) def get_actions(self, group_id, **kwargs): - """ - Get all actions of a group. + """Get all actions of a group. + + https://api.smaxtec.com/api/v2/groups/{group_id}/actions Args: group_id (str): ID of the group which should be updated. @@ -51,8 +53,9 @@ def get_actions(self, group_id, **kwargs): return self.api.get(url_suffix, json=params) def delete_actions(self, group_id, action_id, **kwargs): - """ - Delete an action from a group. + """Delete an action from a group. + + https://api.smaxtec.com/api/v2/groups/{group_id}/actions/{action_id} Args: group_id (str): ID of the group which should be updated. diff --git a/src/sxapi/publicV2/notes.py b/src/sxapi/publicV2/notes.py index 4abf43c..b1b0d3f 100644 --- a/src/sxapi/publicV2/notes.py +++ b/src/sxapi/publicV2/notes.py @@ -8,9 +8,13 @@ def __init__(self, api=None): self.api = api self.path_suffix = "/notes" - def post(self, source, reference_type, reference_id, category, note_event, **kwargs): + def post( + self, source, reference_type, reference_id, category, note_event, **kwargs + ): """Create a new note. + https://api.smaxtec.com/api/v2/notes + Args: source (str): Source of the note reference_type (str): Type of the reference @@ -42,6 +46,8 @@ def post(self, source, reference_type, reference_id, category, note_event, **kwa def get(self, note_id, **kwargs): """Get one note. + https://api.smaxtec.com/api/v2/notes/{note_id} + Args: note_id (str): ID of the desired note **kwargs: Optional parameters of the API call. @@ -61,9 +67,20 @@ def get(self, note_id, **kwargs): url_suffix = self.path_suffix + f"/{note_id}" return self.api.get(url_suffix, json=kwargs) - def put(self, note_id, source, reference_type, reference_id, category, note_event, **kwargs): + def put( + self, + note_id, + source, + reference_type, + reference_id, + category, + note_event, + **kwargs, + ): """Update an existing note. + https://api.smaxtec.com/api/v2/notes/{note_id} + Args: note_id (str): ID of the note to be updated source (str): Source of the note @@ -92,4 +109,4 @@ def put(self, note_id, source, reference_type, reference_id, category, note_even params[k] = v url_suffix = self.path_suffix + f"/{note_id}" - return self.api.put(url_suffix, json=params) \ No newline at end of file + return self.api.put(url_suffix, json=params) diff --git a/src/sxapi/publicV2/observation_groups.py b/src/sxapi/publicV2/observation_groups.py index c54b53b..fe42164 100644 --- a/src/sxapi/publicV2/observation_groups.py +++ b/src/sxapi/publicV2/observation_groups.py @@ -11,6 +11,8 @@ def __init__(self, api=None): def post(self, name, group_type, start_date, organisation_id, **kwargs): """Create a new observation group. + https://api.smaxtec.com/api/v2/organisation_groups + Args: name (str): Name of the observation group. group_type (str): Type of the observation group. @@ -41,6 +43,8 @@ def post(self, name, group_type, start_date, organisation_id, **kwargs): def get_dim_series_line(self, reference_type, reference_id, **kwargs): """Get aggregated DIM line chart data for an organisation. + https://api.smaxtec.com/api/v2/organisation_groups/dim_series_line.json + Args: reference_type (str): Observation group reference type. reference_id (str): ID of Observation group. @@ -67,6 +71,8 @@ def get_dim_series_line(self, reference_type, reference_id, **kwargs): def put(self, group_id, **kwargs): """Update an observation group. + https://api.smaxtec.com/api/v2/organisation_groups/{group_id} + Args: group_id (str): ID of the observation group **kwargs: Optional parameters of the API call. @@ -89,6 +95,8 @@ def put(self, group_id, **kwargs): def get(self, group_id, **kwargs): """Get one observation group by ID. + https://api.smaxtec.com/api/v2/organisation_groups/{group_id} + Args: group_id (str): ID of the observation group **kwargs: Optional parameters of the API call. @@ -111,6 +119,8 @@ def get(self, group_id, **kwargs): def delete(self, group_id, **kwargs): """Delete an observation group. + https://api.smaxtec.com/api/v2/organisation_groups/{group_id} + Args: group_id (str): ID of the observation group **kwargs: Optional parameters of the API call. @@ -133,6 +143,8 @@ def delete(self, group_id, **kwargs): def put_add_animals(self, group_id, animal_ids, **kwargs): """Add animals to an observation group. + https://api.smaxtec.com/api/v2/organisation_groups/{group_id}/add_animals + Args: group_id (str): ID of the observation group animal_ids (:obj:`list` of :obj:`str`): List of animal IDs @@ -157,6 +169,8 @@ def put_add_animals(self, group_id, animal_ids, **kwargs): def put_remove_animals(self, group_id, animal_ids, **kwargs): """Remove animals from an observation group. + https://api.smaxtec.com/api/v2/organisation_groups/{group_id}/remove_animals + Args: group_id (str): ID of the observation group animal_ids (:obj:`list` of :obj:`str`): List of animal IDs @@ -181,6 +195,8 @@ def put_remove_animals(self, group_id, animal_ids, **kwargs): def get_observ_dim_series_bar(self, observation_group_id, **kwargs): """Get aggregated DIM bar char data for an observation group. + https://api.smaxtec.com/api/v2/organisation_groups/{observation_group_id}/observ_dim_series_bar.json + Args: observation_group_id (str): ID of the observation group **kwargs: Optional parameters of the API call. @@ -205,6 +221,8 @@ def get_observ_dim_series_bar(self, observation_group_id, **kwargs): def get_orga_dim_series_bar(self, organisation_id, **kwargs): """Get aggregated DIM bar char data for an organisation. + https://api.smaxtec.com/api/v2/organisation_groups/{organisation_id}/orga_dim_series_bar.json + Args: organisation_id (str): ID of the organisation **kwargs: Optional parameters of the API call. diff --git a/src/sxapi/publicV2/sensordata.py b/src/sxapi/publicV2/sensordata.py index 307fe6e..daa39a5 100644 --- a/src/sxapi/publicV2/sensordata.py +++ b/src/sxapi/publicV2/sensordata.py @@ -5,10 +5,22 @@ from sxapi.publicV2 import PublicAPIV2 +# TODO: This function is located inside the CLI class. + def get_sensor_data_from_animal(api, animal_id, *args, **kwargs): - """ - Performs a get call to PUBLIC_API_V2, to get the sensordata from the given animal_id + """Performs a get call to PUBLIC_API_V2, to get the sensordata from the given animal_id + + Args: + api (PublicAPIV2): Api object to perform the call + animal_id (str): ID of the animal to get the sensordata from + *args: Optional parameters of the API call. + **kwargs: Optional parameters of the API call. + + Returns: + dict: Response from the API. Requested Metric values on success, + error message else. + """ if not isinstance(api, PublicAPIV2): print("This function is only available to PublicAPIV2!") diff --git a/src/sxapi/publicV2/shares.py b/src/sxapi/publicV2/shares.py index 99004d6..d6c2127 100644 --- a/src/sxapi/publicV2/shares.py +++ b/src/sxapi/publicV2/shares.py @@ -11,6 +11,8 @@ def __init__(self, api=None): def post(self, email, organisation_id, **kwargs): """Create a new share. + https://api.smaxtec.com/api/v2/shares + Args: email (str): Email of the user to share organisation_id (str): ID of the organisation to share @@ -36,6 +38,8 @@ def post(self, email, organisation_id, **kwargs): def get(self, share_id, **kwargs): """Get one share. + https://api.smaxtec.com/api/v2/shares/{share_id} + Args: share_id (str): ID of the desired share **kwargs: Optional parameters of the API call. @@ -58,6 +62,8 @@ def get(self, share_id, **kwargs): def put(self, share_id, role, **kwargs): """Update one share. + https://api.smaxtec.com/api/v2/shares/{share_id} + Args: share_id (str): ID of the desired share role (str): Role of the share @@ -83,6 +89,8 @@ def put(self, share_id, role, **kwargs): def delete(self, share_id, **kwargs): """Delete one share. + https://api.smaxtec.com/api/v2/shares/{share_id} + Args: share_id (str): ID of the desired share **kwargs: Optional parameters of the API call. @@ -100,4 +108,4 @@ def delete(self, share_id, **kwargs): params[k] = v url_suffix = self.path_suffix + f"/{share_id}" - return self.api.delete(url_suffix, json=params) \ No newline at end of file + return self.api.delete(url_suffix, json=params) diff --git a/src/sxapi/publicV2/todos.py b/src/sxapi/publicV2/todos.py index 18a6cfe..43be5d6 100644 --- a/src/sxapi/publicV2/todos.py +++ b/src/sxapi/publicV2/todos.py @@ -11,6 +11,8 @@ def __init__(self, api=None): def post(self, todo_type, organisation_id, **kwargs): """Creates a new todo. + https://api.smaxtec.com/api/v2/todos + Args: todo_type (str): Type of the todo to be created organisation_id (str): Id of organisation the todo should be created for @@ -35,6 +37,8 @@ def post(self, todo_type, organisation_id, **kwargs): def put(self, todo_id, **kwargs): """Updates an existing todo. + https://api.smaxtec.com/api/v2/todos/{todo_id} + Args: todo_id (str): Id of the todo which should be updated. **kwargs: Optional parameters of the API call. @@ -55,6 +59,8 @@ def put(self, todo_id, **kwargs): def get(self, todo_id): """Get one todo. + https://api.smaxtec.com/api/v2/todos/{todo_id} + Args: todo_id (str): Id of the desired todo @@ -67,6 +73,8 @@ def get(self, todo_id): def post_comment(self, todo_id, content): """Create a comment for a todo. + https://api.smaxtec.com/api/v2/todos/{todo_id}/comments + Args: todo_id (str): Id of the todo a comment is to be created. content (str): Content of the comment @@ -84,6 +92,8 @@ def post_comment(self, todo_id, content): def delete_comment(self, todo_id, comment_id): """Delete a comment from a todo. + https://api.smaxtec.com/api/v2/todos/{todo_id}/comments/{comment_id} + Args: todo_id (str): Id of the todo a comment is to be deleted. comment_id (str): Id of the comment to delete. @@ -98,6 +108,8 @@ def delete_comment(self, todo_id, comment_id): def put_comment(self, todo_id, comment_id, content): """Update a comment from a todo. + https://api.smaxtec.com/api/v2/todos/{todo_id}/comments/{comment_id} + Args: todo_id (str): Id of the todo a comment is to be updated. comment_id (str): Id of the comment to be updated. diff --git a/src/sxapi/publicV2/users.py b/src/sxapi/publicV2/users.py index 19a6039..b11e45a 100644 --- a/src/sxapi/publicV2/users.py +++ b/src/sxapi/publicV2/users.py @@ -11,6 +11,8 @@ def __init__(self, api=None): def post_activate(self, user_secret, **kwargs): """Active a user with secret. + https://api.smaxtec.com/api/v2/users/activate + Args: user_secret (str): secrete received from registration email. @@ -29,6 +31,8 @@ def post_activate(self, user_secret, **kwargs): def post_credentials(self, user, password, **kwargs): """Create smaxtec api-access-token and an optional firestore-token. + https://api.smaxtec.com/api/v2/users/credentials + Args: user (str): Username/email password (str): User password @@ -55,6 +59,8 @@ def post_credentials(self, user, password, **kwargs): def get_credentials(self, **kwargs): """Retrieve smaxtec api-access-tokens with a JWT Token. + https://api.smaxtec.com/api/v2/users/credentials + Args: **kwargs: Optional parameters of the API call. Find supported parameters under @@ -76,6 +82,8 @@ def get_credentials(self, **kwargs): def post_reset_password(self, secret, new_password, **kwargs): """Reset password with secret. + https://api.smaxtec.com/api/v2/users/reset_password + Args: secret (str): secret received from email request. new_password (str): new password for the user. @@ -98,6 +106,8 @@ def post_reset_password(self, secret, new_password, **kwargs): def get_reset_password_request(self, email, **kwargs): """Request a password reset email. + https://api.smaxtec.com/api/v2/users/reset_password_request + Args: email (str): email of the user. **kwargs: Optional parameters of the API call. @@ -119,6 +129,8 @@ def get_reset_password_request(self, email, **kwargs): def get(self, user_id, **kwargs): """Get one user by id. + https://api.smaxtec.com/api/v2/users/{user_id} + Args: user_id (str): ID of the desired user **kwargs: Optional parameters of the API call. @@ -140,6 +152,8 @@ def get(self, user_id, **kwargs): def get_account(self, user_id, **kwargs): """Get a list of all Accounts of the given user + https://api.smaxtec.com/api/v2/users/{user_id}/account + Args: user_id (str): ID of the desired user **kwargs: Optional parameters of the API call. @@ -147,7 +161,7 @@ def get_account(self, user_id, **kwargs): https://api.smaxtec.com/api/v2/ Returns: - dict: Response of API call. List of Account objects on success, + list[dict]: Response of API call. List of Account objects on success, error message else. """ @@ -162,6 +176,8 @@ def get_account(self, user_id, **kwargs): def get_alarms(self, user_id, **kwargs): """Get a list of all Alarms of the given user + https://api.smaxtec.com/api/v2/users/{user_id}/alarms + Args: user_id (str): ID of the desired user **kwargs: Optional parameters of the API call. @@ -169,7 +185,7 @@ def get_alarms(self, user_id, **kwargs): https://api.smaxtec.com/api/v2/ Returns: - dict: Response of API call. List of Alarm objects on success, + list[dict]: Response of API call. List of Alarm objects on success, error message else. """ @@ -184,6 +200,8 @@ def get_alarms(self, user_id, **kwargs): def put_change_password(self, user_id, old_password, new_password, **kwargs): """Change password of a user with old password. + https://api.smaxtec.com/api/v2/users/{user_id}/change_password + Args: user_id (str): ID of the desired user old_password (str): old password of the user @@ -210,6 +228,8 @@ def put_change_password(self, user_id, old_password, new_password, **kwargs): def post_password_strength(self, user_id, email, password, **kwargs): """Check password strength. + https://api.smaxtec.com/api/v2/users/{user_id}/password_strength + Args: user_id (str): ID of the desired user email (str): email of the user @@ -237,6 +257,8 @@ def post_password_strength(self, user_id, email, password, **kwargs): def get_shares(self, user_id, **kwargs): """Get a list of all Shares of the given user + https://api.smaxtec.com/api/v2/users/{user_id}/shares + Args: user_id (str): ID of the desired user **kwargs: Optional parameters of the API call. @@ -244,7 +266,7 @@ def get_shares(self, user_id, **kwargs): https://api.smaxtec.com/api/v2/ Returns: - dict: Response of API call. List of Share objects on success, + list[dict]: Response of API call. List of Share objects on success, error message else. """ @@ -259,6 +281,8 @@ def get_shares(self, user_id, **kwargs): def post_test_email(self, user_id, **kwargs): """Send a test email to the user. + https://api.smaxtec.com/api/v2/users/{user_id}/test_email + Args: user_id (str): ID of the desired user **kwargs: Optional parameters of the API call. @@ -280,6 +304,8 @@ def post_test_email(self, user_id, **kwargs): def post_test_push(self, user_id, **kwargs): """Send a test push notification to the user. + https://api.smaxtec.com/api/v2/users/{user_id}/test_push + Args: user_id (str): ID of the desired user **kwargs: Optional parameters of the API call. @@ -329,6 +355,8 @@ def put_tokens(self, user_id, token, platform, token_type, **kwargs): def post_tokens(self, user_id, token, platform, token_type, **kwargs): """Adds the token to the user. + https://api.smaxtec.com/api/v2/users/{user_id}/tokens + Args: user_id (str): ID of the desired user token (str): some kind of token @@ -357,6 +385,8 @@ def post_tokens(self, user_id, token, platform, token_type, **kwargs): def delete_tokens(self, user_id, token, **kwargs): """Deletes the token from the user. + https://api.smaxtec.com/api/v2/users/{user_id}/tokens/{token} + Args: user_id (str): ID of the desired user token (str): token to be deleted @@ -379,6 +409,8 @@ def delete_tokens(self, user_id, token, **kwargs): def post_update_metadata(self, user_id, metadata, **kwargs): """Update metadata of a user. + https://api.smaxtec.com/api/v2/users/{user_id}/update_metadata + Args: user_id (str): ID of the desired user metadata (dict): updated metadata