Class: Graphcommons::Signal

Inherits:
API
  • Object
show all
Defined in:
lib/graphcommons.rb

Overview

Changes to the nodes and edges of a graph are carried out by a series of commands called signals in the request body. With these signals you can add, update or delete nodes, edges, node types and edge types.

Mind that :id parameter is required in all calls.

Class Method Summary collapse

Methods inherited from API

check_key, delete, get, post, put, set_key

Class Method Details

.edge_create(id, options) ⇒ Object

This signal type is used for creating edges. Source and target nodes for the edge will be created if they don’t already exist. Only one instance of edgetype is allowed between the same nodes. However, there could be multiple edges between the same node pair, as long as the their edge types are different.

Upon saving this signal a new edge id is created. The type of the edge is matched with a predefined edge type from the hub/graph. If the edge type does not already exist, a new edge type is created.

Required options: :from_type, :from_name, :to_type, :to_name, :name

graphcommons.github.io/api-v1/#edge_create



307
308
309
310
# File 'lib/graphcommons.rb', line 307

def self.edge_create id, options
  options[:action] = :edge_create
  self._signal id, options
end

.edge_delete(id, options) ⇒ Object

This signal type is used for deleting edges.

graphcommons.github.io/api-v1/#edge_delete



343
344
345
346
# File 'lib/graphcommons.rb', line 343

def self.edge_delete id, options
  options[:action] = :edge_delete
  self._signal id, options
end

.edge_update(id, options) ⇒ Object

This signal type is used for updating an edge. All fields except for id will be updated in the node.

Required options: :from, :to

graphcommons.github.io/api-v1/#edge_update



327
328
329
330
# File 'lib/graphcommons.rb', line 327

def self.edge_update id, options
  options[:action] = :edge_update
  self._signal id, options
end

.edgetype_delete(id, options) ⇒ Object



367
368
369
370
# File 'lib/graphcommons.rb', line 367

def self.edgetype_delete id, options
  options[:action] = :edgetype_delete
  self._signal id, options
end

.edgetype_update(id, options) ⇒ Object



355
356
357
358
# File 'lib/graphcommons.rb', line 355

def self.edgetype_update id, options
  options[:action] = :edgetype_update
  self._signal id, options
end

.node_create(id, options) ⇒ Object

This signal type is used for creating nodes. All signals of this type must define a type and name key. type - name pairs must be unique.

Upon saving this signal, a new node id is created. The type of the node is matched with a predefined node type from the hub/graph. If the node type does not already exist, a node type is created.

Required options: :name, :type

graphcommons.github.io/api-v1/#node_create



289
290
291
292
# File 'lib/graphcommons.rb', line 289

def self.node_create id, options
  options[:action] = :node_create
  self._signal id, options
end

.node_delete(id, options) ⇒ Object

This signal type is used for deleting nodes.

graphcommons.github.io/api-v1/#node_delete



335
336
337
338
# File 'lib/graphcommons.rb', line 335

def self.node_delete id, options
  options[:action] = :node_delete
  self._signal id, options
end

.node_update(id, options) ⇒ Object

This signal type is used for updating a node. All fields except for id will be updated in the node.

graphcommons.github.io/api-v1/#node_update



316
317
318
319
# File 'lib/graphcommons.rb', line 316

def self.node_update id, options
  options[:action] = :node_update
  self._signal id, options
end

.nodetype_delete(id, options) ⇒ Object



361
362
363
364
# File 'lib/graphcommons.rb', line 361

def self.nodetype_delete id, options
  options[:action] = :nodetype_delete
  self._signal id, options
end

.nodetype_update(id, options) ⇒ Object



349
350
351
352
# File 'lib/graphcommons.rb', line 349

def self.nodetype_update id, options
  options[:action] = :nodetype_update
  self._signal id, options
end