REST API¶
When a page is started, REST API endpoints are exposed under /api.
This API may be used to update a page from an external script.
See awe.api_client.APIClient source for details on specific endpoints. The code is short and pretty
self explanatory.
Python Client¶
-
class
awe.api_client.APIClient(host='127.0.0.1', port=8080)[source]¶ REST API client.
Can be used to update a running page from an external script.
Parameters: - host –
aweserver host. - port –
aweserver port.
-
get_elements(include_data=False, include_props=False)[source]¶ Get all elements currently registered.
Parameters: - include_data – Should element data be included in the response.
- include_props – Should element props be included in the response.
-
get_element(element_id)[source]¶ Get a single registered element.
Parameters: element_id – The element id.
-
new_element(obj, params=None, element_id=None, root_id=None, parent_id=None, new_root=False)[source]¶ Create a new element. Equivalent to calling the
new()method on elements.Parameters: - obj – The
objargument as expected by thenew()method. - params – Params to pass on to the
new()method invocation. - element_id – Optionally specify an
element_id. (one will be generated otherwise) - root_id – Optionally specify a different root to create the element under.
If not specified, and
parent_idis not supplied, the mainpageroot will be used. - parent_id – Optionally specify the element to call the
new()method on. - new_root – Pass
Trueto create the element under a new root.
- obj – The
-
remove_element(element_id)[source]¶ Remove an element from the page.
Parameters: element_id – The element id.
-
new_prop(element_id, name)[source]¶ Create a new prop child. Equivalent to calling
new_prop()on an element.Parameters: - element_id – The element id to call
new_propon. - name – The prop name.
- element_id – The element id to call
-
update_data(element_id, data)[source]¶ Update the element data. Equivalent to calling
update_data()on an element.Parameters: - element_id – The element id to call
update_dataon. - data – The data to set on the element.
- element_id – The element id to call
-
update_props(element_id, props)[source]¶ Update the element props. Equivalent to calling
update_props()on an element.Parameters: - element_id – The element id to call
update_propson. - props – The props to set on the element.
- element_id – The element id to call
-
update_prop(element_id, path, value)[source]¶ Update an element prop. Equivalent to calling
update_prop()on an element.Parameters: - element_id – The element id to call
update_propon. - path – The prop path.
- value – The prop value.
- element_id – The element id to call
-
call_method(element_id, method_name, kwargs=None)[source]¶ Call a method on an element. Useful when working with elements such as a table or a chart that expose methods to modify their internal state.
Parameters: - element_id – The element id to call the specified method on.
- method_name – The method to call.
- kwargs – Keyword arguments to pass to the method invocation.
-
get_variable(variable_id)[source]¶ Get a single registered variable.
Parameters: variable_id – The variable id.
-
new_variable(value, variable_id=None)[source]¶ Create a new variable.
Parameters: - value – The variable’s initial value.
- variable_id – Optionally, supply a variable id, one will be generated otherwise.
- host –