Exemple #1
0
 def delete(self, device_id):
     """ Delete a device given its identifier """
     try:
         device_logic.remove_device(device_id)
     except HestiaException as error:
         return handle_hestia_exception(error)
     except Exception as error:
         return handle_standard_exception(error)
     return "", 204
Exemple #2
0
 def get(self):
     """ List all devices """
     try:
         devices = device_logic.get_all_devices()
     except HestiaException as error:
         return handle_hestia_exception(error)
     except Exception as error:
         return handle_standard_exception(error)
     return devices
Exemple #3
0
 def get(self, device_id):
     """ Fetch a device given its identifier """
     try:
         return_device = device_logic.get_device(device_id)
     except HestiaException as error:
         return handle_hestia_exception(error)
     except Exception as error:
         return handle_standard_exception(error)
     return return_device
 def get(self, collection):
     """ Fetch all plugins of an collection """
     try:
         return_plugins = plugin_logic.get_plugins(collection)
     except HestiaException as error:
         return handle_hestia_exception(error)
     except Exception as error:
         return handle_standard_exception(error)
     return return_plugins
 def get(self):
     """ Fetch all the collections that have plugins installed """
     try:
         return_collection = plugin_logic.get_collections()
     except HestiaException as error:
         return handle_hestia_exception(error)
     except Exception as error:
         return handle_standard_exception(error)
     return return_collection
 def get(self, device_id, activator_id):
     """ Fetch a given activator of a device """
     try:
         return_activator = activator_logic.get_activator(
             device_id, activator_id)
     except HestiaException as error:
         return handle_hestia_exception(error)
     except Exception as error:
         return handle_standard_exception(error)
     return return_activator
Exemple #7
0
 def post(self):
     """ Post a new device """
     try:
         json_required_info = namespace.apis[0].payload
         device_logic.create_new_device(json_required_info)
     except HestiaException as error:
         return handle_hestia_exception(error)
     except Exception as error:
         return handle_standard_exception(error)
     return "new device", 201
Exemple #8
0
 def put(self, device_id):
     """ Put a new name for device given its identifier """
     try:
         new_name = namespace.apis[0].payload["name"]
         device_logic.change_device_name(device_id, new_name)
     except HestiaException as error:
         return handle_hestia_exception(error)
     except Exception as error:
         return handle_standard_exception(error)
     return "name changed", 201
 def get(self, collection, plugin_name):
     """ Fetch the required information of a plugin based on its collection and name """
     try:
         return_required_info = plugin_logic.get_required_info(
             collection, plugin_name)
     except HestiaException as error:
         return handle_hestia_exception(error)
     except Exception as error:
         return handle_standard_exception(error)
     return return_required_info
 def post(self, device_id, activator_id):
     """ Post a given activator of a device """
     try:
         value = namespace.apis[0].payload["state"]
         activator_logic.change_activator_state(device_id, activator_id,
                                                value)
     except HestiaException as error:
         return handle_hestia_exception(error)
     except Exception as error:
         return handle_standard_exception(error)
     return "state updated", 201