-
Notifications
You must be signed in to change notification settings - Fork 4
Node API
Working with Graph Nodes (a.k.a. Vertices).
Creates a new GraphitNode
object from data
.
-
session: An instance of
graphit.GraphitSession
-
data: A
dict
(ordict
-like) object with the node's attributes as key–value–pairs. Needs to contain at leastogit/_type
orogit/_id
!
None
Loads the vertex with the respective ogit/_id
from the HIRO Graph and creates a new GraphitNode
object with that data.
-
session: An instance of
graphit.GraphitSession
-
ogit_id: A
str
containing theogit/_id
of an existing node in the HIRO Graph.
Create the corresponding vertex in the HIRO Graph. If the node data includes an ogit/_owner
attribute (or the owner
parameter is used) and that owner does not exist in the HIRO Graph, yet, it will be created as well, as ogit/Organization
.
-
owner: Override the
ogit/_owner
attribute.
Create an Edge of type ogit_type
from another instance of GraphitNode
to this node.
- reverse: Reverse the direction of the Edge, it will be directed from this node to the other node.
Update the node in the HIRO Graph.
None.
Update or create the node in the HIRO Graph. If replace
is true
-
replace:
bool
, ifTrue
, the existing node will be replaced by the new data, meaning: all attributes that are in the Vertex in the HIRO Graph but not in theGraphitNode
, will be deleted. -
owner: Override the
ogit/_owner
attribute.
Update the GraphitNode
instance with the latest data from the HIRO Graph.
None.
Delete the corresponding Vertex in the HIRO Graph.
None.
Get the value of the attribute attr
, if it exists, None
otherwise.
-
attr: A
str
containing the name of the attribute to get the value of.
None.
Set the value of the attribute attr
to value
and update the Vertex in the HIRO Graph.
-
attr: A
str
containing the name of the attribute to set. -
value: A
str
containing the value the attribute should be set to.
Remove the attribute attr
from the GraphitNode
and update the Vertex in the HIRO Graph.
-
attr: A
str
containing the name of the attribute to delete.
Get a str
containing the JSON representation of the GraphitNode
.
- pretty_print: Insert line breaks and indentation.
-
ValueError
If you set an attribute to a non–JSON–serializable value and calljson()
afterwards.
Subclass of graphit.GraphitNode
to handle binary Attachments. Supports all methods of GraphitNode
plus these additional ones:
Get the binary content of the attachment, returns bytes
.
Set the binary content of the attachment.
-
content: The raw binary content to upload as
bytes
.
Subclass of graphit.GraphitNode
to handle Timeseries. Supports all methods of GraphitNode
plus these additional ones:
Get the values of a Timeseries. Returns a generator which will yield the actual results.
-
start: A timestamp in ms (
int
), only values from that point in time on will be included. -
end: A timestamp in ms (
int
), only values before that point in time on will be included.
Add values to a Timeseries.
-
values: A
list
ofdict
s containing timeseries entries:[ { 'timestamp': <TIMESTAMP1>, 'value': "<VALUE1>" }, { 'timestamp': <TIMESTAMP2>, 'value': "<VALUE2>" } ]
-
size: An
int
orNone
. In case of anint
, the list of values is split into chunks ofsize
and each chunk is written to the graph in a separate request.