Trait fxbox_taxonomy::api::API [] [src]

pub trait API: Send {
    type WatchGuard;
    fn get_nodes(&self, &Vec<NodeSelector>) -> Vec<Node>;
    fn put_node_tag(&self, set: &Vec<NodeSelector>, tags: &Vec<String>) -> usize;
    fn delete_node_tag(&self, set: &Vec<NodeSelector>, tags: String) -> usize;
    fn get_input_channels(&self, &Vec<GetSelector>) -> Vec<Channel<Get>>;
    fn get_output_channels(&self, &Vec<SetSelector>) -> Vec<Channel<Set>>;
    fn put_input_tag(&self, &Vec<GetSelector>, &Vec<String>) -> usize;
    fn put_output_tag(&self, &Vec<SetSelector>, &Vec<String>) -> usize;
    fn delete_input_tag(&self, &Vec<GetSelector>, &Vec<String>) -> usize;
    fn delete_output_tag(&self, &Vec<GetSelector>, &Vec<String>) -> usize;
    fn get_channel_value(&self, &Vec<GetSelector>) -> Vec<(Id<Get>, Result<Value, Error>)>;
    fn put_channel_value(&self, &Vec<SetSelector>, Value) -> Vec<(Id<Set>, Result<(), Error>)>;
    fn register_channel_watch(&self, Vec<WatchOptions>, cb: Box<Fn(WatchEvent) + Send + 'static>) -> Self::WatchGuard;
}

A handle to the public API.

Associated Types

type WatchGuard

A value that causes a disconnection once it is dropped.

Required Methods

fn get_nodes(&self, &Vec<NodeSelector>) -> Vec<Node>

Get the metadata on nodes matching some conditions.

A call to API::get_nodes(vec![req1, req2, ...]) will return the metadata on all nodes matching either req1 or req2 or ...

REST API

GET /api/v1/nodes

Gets

Any JSON that can be deserialized to a Vec<NodeSelector>. See the implementation of NodeSelector for details.

Example

Selector all doors in the entrance (tags door, entrance) that support output channel OpenClose

[{
  "tags": ["entrance", "door"],
  "inputs": [
    {
      "kind": {
        "Exactly": {
          "OpenClose": []
        }
      }
    }
  ]
}]

Errors

In case of syntax error, Error 400, accompanied with a somewhat human-readable JSON string detailing the error.

Success

A JSON representing an array of Node. See the implementation of Node for details.

Example

[{
  "tags": ["entrance", "door", "somevendor"],
  "id: "some-node-id",
  "inputs": [],
  "outputs": [
    "tags": [...],
    "id": "some-channel-id",
    "node": "some-node-id",
    "last_seen": "some-date",
    "mechanism": {
      "Set":  {
        "kind": {
          "OnOff": []
        },
        "push": [5000],
        "updated": "some-date",
      }
    }
  ]
}]

fn put_node_tag(&self, set: &Vec<NodeSelector>, tags: &Vec<String>) -> usize

Label a set of nodes with a set of tags.

A call to API::put_node_tag(vec![req1, req2, ...], vec![tag1, ...]) will label all the nodes matching either req1 or req2 or ... with tag1, ... and return the number of nodes matching any of the selectors.

Some of the nodes may already be labelled with tag1, or tag2, ... They will not change state. They are counted in the resulting usize nevertheless.

Note that this call is not live. In other words, if nodes are added after the call, they will not be affected.

REST API

POST /api/v1/nodes/tag

Gets

Any JSON that can be deserialized to

{
  set: Vec<NodeSelector>,
  tags: Vec<String>,
}

Errors

In case of syntax error, Error 400, accompanied with a somewhat human-readable JSON string detailing the error.

Success

A JSON string representing a number.

fn delete_node_tag(&self, set: &Vec<NodeSelector>, tags: String) -> usize

Remove a set of tags from a set of nodes.

A call to API::delete_node_tag(vec![req1, req2, ...], vec![tag1, ...]) will remove from all the nodes matching either req1 or req2 or ... all of the tags tag1, ... and return the number of nodes matching any of the selectors.

Some of the nodes may not be labelled with tag1, or tag2, ... They will not change state. They are counted in the resulting usize nevertheless.

Note that this call is not live. In other words, if nodes are added after the call, they will not be affected.

REST API

DELETE /api/v1/nodes/tag

Gets

Any JSON that can be deserialized to

{
  set: Vec<NodeSelector>,
  tags: Vec<String>,
}

Errors

In case of syntax error, Error 400, accompanied with a somewhat human-readable JSON string detailing the error.

Success

A JSON representing a number.

fn get_input_channels(&self, &Vec<GetSelector>) -> Vec<Channel<Get>>

Get a list of inputs matching some conditions

REST API

GET /api/v1/channels

fn get_output_channels(&self, &Vec<SetSelector>) -> Vec<Channel<Set>>

fn put_input_tag(&self, &Vec<GetSelector>, &Vec<String>) -> usize

Label a set of channels with a set of tags.

A call to API::put_{input, output}_tag(vec![req1, req2, ...], vec![tag1, ...]) will label all the channels matching either req1 or req2 or ... with tag1, ... and return the number of channels matching any of the selectors.

Some of the channels may already be labelled with tag1, or tag2, ... They will not change state. They are counted in the resulting usize nevertheless.

Note that this call is not live. In other words, if channels are added after the call, they will not be affected.

REST API

POST /api/v1/channels/tag

Gets

Any JSON that can be deserialized to

{
  set: Vec<GetSelector>,
  tags: Vec<String>,
}

or ignore { set: Vec<SetSelector>, tags: Vec<String>, }

Errors

In case of syntax error, Error 400, accompanied with a somewhat human-readable JSON string detailing the error.

Success

A JSON representing a number.

fn put_output_tag(&self, &Vec<SetSelector>, &Vec<String>) -> usize

fn delete_input_tag(&self, &Vec<GetSelector>, &Vec<String>) -> usize

Remove a set of tags from a set of channels.

A call to API::delete_{input, output}_tag(vec![req1, req2, ...], vec![tag1, ...]) will remove from all the channels matching either req1 or req2 or ... all of the tags tag1, ... and return the number of channels matching any of the selectors.

Some of the channels may not be labelled with tag1, or tag2, ... They will not change state. They are counted in the resulting usize nevertheless.

Note that this call is not live. In other words, if channels are added after the call, they will not be affected.

REST API

DELETE /api/v1/channels/tag

Gets

Any JSON that can be deserialized to

{
  set: Vec<GetSelector>,
  tags: Vec<String>,
}

or ignore { set: Vec<SetSelector>, tags: Vec<String>, }

Errors

In case of syntax error, Error 400, accompanied with a somewhat human-readable JSON string detailing the error.

Success

A JSON representing a number.

fn delete_output_tag(&self, &Vec<GetSelector>, &Vec<String>) -> usize

fn get_channel_value(&self, &Vec<GetSelector>) -> Vec<(Id<Get>, Result<Value, Error>)>

Read the latest value from a set of channels

REST API

GET /api/v1/channels/value

fn put_channel_value(&self, &Vec<SetSelector>, Value) -> Vec<(Id<Set>, Result<(), Error>)>

Send one value to a set of channels

REST API

POST /api/v1/channels/value

fn register_channel_watch(&self, Vec<WatchOptions>, cb: Box<Fn(WatchEvent) + Send + 'static>) -> Self::WatchGuard

Watch for any change

WebSocket API

/api/v1/channels/watch

Implementors