Handling Vertices
Examples will explain the REST API to the graph module on the social graph:
Create a vertex
create a new vertex
POST /_api/gharial/{graph-name}/vertex/{collection-name}
Adds a vertex to the given collection.
free style json body
Example:
shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/gharial/social/vertex/male <<EOF
{
"name" : "Francis"
}
EOF
HTTP/1.1 202 Accepted
etag: _UHcg1WO---
content-type: application/json; charset=utf-8
{
"error" : false,
"vertex" : {
"_id" : "male/7784",
"_key" : "7784",
"_rev" : "_UHcg1WO---"
},
"code" : 202
}
Path Parameters
- graph-name (required): The name of the graph.
- collection-name (required): The name of the vertex collection the vertex belongs to.
Query Parameters
- waitForSync (optional): Define if the request should wait until synced to disk.
Post Body
storeThisObject (required): The body has to be the JSON object to be stored.
Return Codes
- 201: Returned if the vertex could be added and waitForSync is true.
- 202: Returned if the request was successful but waitForSync is false.
- 404: Returned if no graph or no vertex collection with this name could be found.
Examples
shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/gharial/social/vertex/male <<EOF
{
"name" : "Francis"
}
EOF
HTTP/1.1 202 Accepted
etag: _UHcg1WO---
content-type: application/json; charset=utf-8
{
"error" : false,
"vertex" : {
"_id" : "male/7784",
"_key" : "7784",
"_rev" : "_UHcg1WO---"
},
"code" : 202
}
shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/gharial/social/vertex/male <<EOF
{
"name" : "Francis"
}
EOF
HTTP/1.1 202 Accepted
etag: _UHcg1WO---
content-type: application/json; charset=utf-8
Get a vertex
fetches an existing vertex
GET /_api/gharial/{graph-name}/vertex/{collection-name}/{vertex-key}
Gets a vertex from the given collection.
Example:
shell> curl --dump - http://localhost:8529/_api/gharial/social/vertex/female/alice
HTTP/1.1 200 OK
etag: _UHcg43m---
content-type: application/json; charset=utf-8
{
"error" : false,
"vertex" : {
"_key" : "alice",
"_id" : "female/alice",
"_rev" : "_UHcg43m---",
"name" : "Alice"
},
"code" : 200
}
Path Parameters
- graph-name (required): The name of the graph.
- collection-name (required): The name of the vertex collection the vertex belongs to.
- vertex-key (required): The _key attribute of the vertex.
Header Parameters
- if-match (optional): If the "If-Match" header is given, then it must contain exactly one etag. The document is returned, if it has the same revision as the given etag. Otherwise a HTTP 412 is returned. As an alternative you can supply the etag in an attribute rev in the URL.
Return Codes
- 200: Returned if the vertex could be found.
- 404: Returned if no graph with this name, no vertex collection or no vertex with this id could be found.
- 412: Returned if if-match header is given, but the documents revision is different.
Examples
shell> curl --dump - http://localhost:8529/_api/gharial/social/vertex/female/alice
HTTP/1.1 200 OK
etag: _UHcg43m---
content-type: application/json; charset=utf-8
{
"error" : false,
"vertex" : {
"_key" : "alice",
"_id" : "female/alice",
"_rev" : "_UHcg43m---",
"name" : "Alice"
},
"code" : 200
}
shell> curl --dump - http://localhost:8529/_api/gharial/social/vertex/female/alice
HTTP/1.1 200 OK
etag: _UHcg43m---
content-type: application/json; charset=utf-8
Modify a vertex
replace an existing vertex
PATCH /_api/gharial/{graph-name}/vertex/{collection-name}/{vertex-key}
Updates the data of the specific vertex in the collection.
free style json body
Example:
shell> curl -X PATCH --data-binary @- --dump - http://localhost:8529/_api/gharial/social/vertex/female/alice <<EOF
{
"age" : 26
}
EOF
HTTP/1.1 202 Accepted
etag: _UHcg676---
content-type: application/json; charset=utf-8
{
"error" : false,
"vertex" : {
"_id" : "female/alice",
"_key" : "alice",
"_rev" : "_UHcg676---",
"_oldRev" : "_UHcg67a---"
},
"code" : 202
}
Path Parameters
- graph-name (required): The name of the graph.
- collection-name (required): The name of the vertex collection the vertex belongs to.
- vertex-key (required): The _key attribute of the vertex.
Query Parameters
- waitForSync (optional): Define if the request should wait until synced to disk.
- keepNull (optional): Define if values set to null should be stored. By default the key is not removed from the document.
Header Parameters
- if-match (optional): If the "If-Match" header is given, then it must contain exactly one etag. The document is updated, if it has the same revision as the given etag. Otherwise a HTTP 412 is returned. As an alternative you can supply the etag in an attribute rev in the URL.
Post Body
replaceAttributes (required): The body has to contain a JSON object containing exactly the attributes that should be replaced.
Return Codes
- 200: Returned if the vertex could be updated.
- 202: Returned if the request was successful but waitForSync is false.
- 404: Returned if no graph with this name, no vertex collection or no vertex with this id could be found.
- 412: Returned if if-match header is given, but the documents revision is different.
Examples
shell> curl -X PATCH --data-binary @- --dump - http://localhost:8529/_api/gharial/social/vertex/female/alice <<EOF
{
"age" : 26
}
EOF
HTTP/1.1 202 Accepted
etag: _UHcg676---
content-type: application/json; charset=utf-8
{
"error" : false,
"vertex" : {
"_id" : "female/alice",
"_key" : "alice",
"_rev" : "_UHcg676---",
"_oldRev" : "_UHcg67a---"
},
"code" : 202
}
shell> curl -X PATCH --data-binary @- --dump - http://localhost:8529/_api/gharial/social/vertex/female/alice <<EOF
{
"age" : 26
}
EOF
HTTP/1.1 202 Accepted
etag: _UHcg676---
content-type: application/json; charset=utf-8
Replace a vertex
replaces an existing vertex
PUT /_api/gharial/{graph-name}/vertex/{collection-name}/{vertex-key}
Replaces the data of a vertex in the collection.
free style json body
Example:
shell> curl -X PUT --data-binary @- --dump - http://localhost:8529/_api/gharial/social/vertex/female/alice <<EOF
{
"name" : "Alice Cooper",
"age" : 26
}
EOF
HTTP/1.1 202 Accepted
etag: _UHcg9QW---
content-type: application/json; charset=utf-8
{
"error" : false,
"vertex" : {
"_id" : "female/alice",
"_key" : "alice",
"_rev" : "_UHcg9QW---",
"_oldRev" : "_UHcg9P6---"
},
"code" : 202
}
Path Parameters
- graph-name (required): The name of the graph.
- collection-name (required): The name of the vertex collection the vertex belongs to.
- vertex-key (required): The _key attribute of the vertex.
Query Parameters
- waitForSync (optional): Define if the request should wait until synced to disk.
Header Parameters
- if-match (optional): If the "If-Match" header is given, then it must contain exactly one etag. The document is updated, if it has the same revision as the given etag. Otherwise a HTTP 412 is returned. As an alternative you can supply the etag in an attribute rev in the URL.
Post Body
storeThisJsonObject (required): The body has to be the JSON object to be stored.
Return Codes
- 200: Returned if the vertex could be replaced.
- 202: Returned if the request was successful but waitForSync is false.
- 404: Returned if no graph with this name, no vertex collection or no vertex with this id could be found.
- 412: Returned if if-match header is given, but the documents revision is different.
Examples
shell> curl -X PUT --data-binary @- --dump - http://localhost:8529/_api/gharial/social/vertex/female/alice <<EOF
{
"name" : "Alice Cooper",
"age" : 26
}
EOF
HTTP/1.1 202 Accepted
etag: _UHcg9QW---
content-type: application/json; charset=utf-8
{
"error" : false,
"vertex" : {
"_id" : "female/alice",
"_key" : "alice",
"_rev" : "_UHcg9QW---",
"_oldRev" : "_UHcg9P6---"
},
"code" : 202
}
shell> curl -X PUT --data-binary @- --dump - http://localhost:8529/_api/gharial/social/vertex/female/alice <<EOF
{
"name" : "Alice Cooper",
"age" : 26
}
EOF
HTTP/1.1 202 Accepted
etag: _UHcg9QW---
content-type: application/json; charset=utf-8
Remove a vertex
removes a vertex from a graph
DELETE /_api/gharial/{graph-name}/vertex/{collection-name}/{vertex-key}
Removes a vertex from the collection.
Example:
shell> curl -X DELETE --dump - http://localhost:8529/_api/gharial/social/vertex/female/alice
HTTP/1.1 202 Accepted
content-type: application/json; charset=utf-8
{
"error" : false,
"removed" : true,
"code" : 202
}
Path Parameters
- graph-name (required): The name of the graph.
- collection-name (required): The name of the vertex collection the vertex belongs to.
- vertex-key (required): The _key attribute of the vertex.
Query Parameters
- waitForSync (optional): Define if the request should wait until synced to disk.
Header Parameters
- if-match (optional): If the "If-Match" header is given, then it must contain exactly one etag. The document is updated, if it has the same revision as the given etag. Otherwise a HTTP 412 is returned. As an alternative you can supply the etag in an attribute rev in the URL.
Return Codes
- 200: Returned if the vertex could be removed.
- 202: Returned if the request was successful but waitForSync is false.
- 404: Returned if no graph with this name, no vertex collection or no vertex with this id could be found.
- 412: Returned if if-match header is given, but the documents revision is different.
Examples
shell> curl -X DELETE --dump - http://localhost:8529/_api/gharial/social/vertex/female/alice
HTTP/1.1 202 Accepted
content-type: application/json; charset=utf-8
{
"error" : false,
"removed" : true,
"code" : 202
}
shell> curl -X DELETE --dump - http://localhost:8529/_api/gharial/social/vertex/female/alice
HTTP/1.1 202 Accepted
content-type: application/json; charset=utf-8