Exemplo n.º 1
0
 def create(cls, **kwargs):
     path = 'commands'
     response = post(path, kwargs)
     if WiaResource.is_success(response):
         return cls(**response.json())
     else:
         return WiaResource.error_response(response)
Exemplo n.º 2
0
 def create(cls, **kwargs):
     path = 'devices'
     response = post(path, kwargs)
     if WiaResource.is_success(response):
         return cls(**WiaResource.json_converter(response))
     else:
         return WiaResource.error_response(response)
Exemplo n.º 3
0
 def create(cls, **kwargs):
     """
     Creates a Space in Wia for devices
     :param kwargs:
     :return: Returns a newly created space
     """
     path = 'spaces'
     response = post(path, kwargs)
     if WiaResource.is_success(response):
         return cls(**response.json())
     else:
         return WiaResource.error_response(response)
Exemplo n.º 4
0
 def publish(cls, **kwargs):
     path = 'locations'
     if Wia().Stream.connected and Wia().client_id is not None:
         topic = 'devices/' + Wia().client_id + '/' + path
         Wia().Stream.publish(topic=topic, **kwargs)
         return cls()
     else:
         response = post(path, kwargs)
         if WiaResource.is_success(response):
             return cls(**response.json())
         else:
             return WiaResource.error_response(response)
Exemplo n.º 5
0
    def run(cls, **kwargs):

        if Wia().Stream.connected and Wia().client_id is not None:
            command = 'devices/' + Wia().client_id + '/commands/' + (
                kwargs['slug'] or kwargs['name']) + '/run'
            Wia().Stream.run(command=command)
            return cls()
        else:
            response = post('commands/run', kwargs)
            if WiaResource.is_success(response):
                return cls(**response.json())
            else:
                return WiaResource.error_response(response)
Exemplo n.º 6
0
 def publish(cls, **kwargs):
     path = 'events'
     if not ('file' in kwargs) and Wia().Stream.connected and Wia(
     ).client_id is not None:
         topic = 'devices/' + Wia(
         ).client_id + '/' + path + '/' + kwargs['name']
         Wia().Stream.publish(topic=topic, **kwargs)
         return cls()
     else:
         response = post(path, kwargs)
         if WiaResource.is_success(response):
             return cls(**WiaResource.json_converter(response))
         else:
             return WiaResource.error_response(response)
Exemplo n.º 7
0
 def create(cls, kwargs):
     response = post('auth/token', kwargs)
     if WiaResource.is_success(response):
         return cls(**response.json())
     else:
         return WiaResource.error_response(response)