Exemplo n.º 1
0
def element(client, label, mac, **kwargs):
    """List elements for a label.

    List elements for a given LABEL.

    Add, remove or replace sensors from the LABEL by using the --add,
    --remove or --replace arguments respectively. Note that you can
    specify "none" with these to indicate an empty list.

    """
    label = Label.lookup(client, label)

    actions = lookup_label_action_resources(client, Element, mac=mac, **kwargs)

    if actions.add is not None:
        label.add_elements(actions.add)

    if actions.remove is not None:
        label.remove_elements(actions.remove)

    if actions.replace is not None:
        label.update_elements(actions.replace)

    elements = label.elements()
    Element.display(client, elements, **kwargs)
Exemplo n.º 2
0
def element(client, sensor, mac):
    """Get the element for a sensor.

    Gets the element a given SENSOR was last seen connected to.
    """
    sensor = Sensor.lookup(client, sensor, mac=mac, include=[Element])
    element = sensor.element(use_included=True)
    Element.display(client, [element] if element else [])
Exemplo n.º 3
0
def element(client, sensor, mac):
    """Get the element for a sensor.

    Gets the element a given SENSOR was last seen connected to.
    """
    sensor = Sensor.lookup(client, sensor, mac=mac, include=[Element])
    element = sensor.element(use_included=True)
    Element.display(client, [element] if element else [])
Exemplo n.º 4
0
def update(client, element, name, mac, **kwargs):
    """Updates the attributes of a element.

    Updates the attributes of a given ELEMENT.
    """
    element = Element.lookup(client, element, mac=mac)
    element = element.update(name=name)
    include = [Sensor]
    element = Element.lookup(client, element.id, mac=mac, include=include)
    Element.display(client, [element], include=include)
Exemplo n.º 5
0
def update(client, element, name, mac, **kwargs):
    """Updates the attributes of a element.

    Updates the attributes of a given ELEMENT.
    """
    element = Element.lookup(client, element, mac=mac)
    element = element.update(attributes={
        'name': name
    })
    include = [Sensor]
    element = Element.lookup(client, element.id, mac=mac, include=include)
    Element.display(client, [element], include=include)
Exemplo n.º 6
0
def list(client, element, mac, **kwargs):
    """List elements.

    Lists information for a given ELEMENT or all elements in the
    organization.

    """
    include = [Sensor]
    if element:
        elements = [Element.lookup(client, element, mac=mac, include=include)]
    else:
        elements = Element.all(client, include=include)
    Element.display(client, elements, include=include)
Exemplo n.º 7
0
def list(client, element, mac, **kwargs):
    """List elements.

    Lists information for a given ELEMENT or all elements in the
    organization.

    """
    include = [Sensor]
    if element:
        elements = [Element.lookup(client, element, mac=mac, include=include)]
    else:
        metadata = kwargs.get('metadata') or None
        elements = Element.where(client, include=include, metadata=metadata)
    Element.display(client, elements, include=include)