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



296
297
298
299
# File 'lib/graphcommons.rb', line 296

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



332
333
334
335
# File 'lib/graphcommons.rb', line 332

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



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

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

.edgetype_delete(id, options) ⇒ Object



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

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

.edgetype_update(id, options) ⇒ Object



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

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



278
279
280
281
# File 'lib/graphcommons.rb', line 278

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



324
325
326
327
# File 'lib/graphcommons.rb', line 324

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



305
306
307
308
# File 'lib/graphcommons.rb', line 305

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

.nodetype_delete(id, options) ⇒ Object



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

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

.nodetype_update(id, options) ⇒ Object



338
339
340
341
# File 'lib/graphcommons.rb', line 338

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