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.
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
content-type: application/json; charset=utf-8
etag: _VTxSdRW---
x-content-type-options: nosniff
{
"error" : false,
"vertex" : {
"_id" : "male/7816",
"_key" : "7816",
"_rev" : "_VTxSdRW---"
},
"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.
Request Body (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
content-type: application/json; charset=utf-8
etag: _VTxSdRW---
x-content-type-options: nosniff
{
"error" : false,
"vertex" : {
"_id" : "male/7816",
"_key" : "7816",
"_rev" : "_VTxSdRW---"
},
"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
content-type: application/json; charset=utf-8
etag: _VTxSdRW---
x-content-type-options: nosniff
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
content-type: application/json; charset=utf-8
etag: _VTxSeNa---
x-content-type-options: nosniff
{
"error" : false,
"vertex" : {
"_key" : "alice",
"_id" : "female/alice",
"_rev" : "_VTxSeNa---",
"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
content-type: application/json; charset=utf-8
etag: _VTxSeNa---
x-content-type-options: nosniff
{
"error" : false,
"vertex" : {
"_key" : "alice",
"_id" : "female/alice",
"_rev" : "_VTxSeNa---",
"name" : "Alice"
},
"code" : 200
}
shell> curl --dump - http://localhost:8529/_api/gharial/social/vertex/female/alice
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
etag: _VTxSeNa---
x-content-type-options: nosniff
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.
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
content-type: application/json; charset=utf-8
etag: _VTxSeym---
x-content-type-options: nosniff
{
"error" : false,
"vertex" : {
"_id" : "female/alice",
"_key" : "alice",
"_rev" : "_VTxSeym---",
"_oldRev" : "_VTxSeyO---"
},
"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.
Request Body (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
content-type: application/json; charset=utf-8
etag: _VTxSeym---
x-content-type-options: nosniff
{
"error" : false,
"vertex" : {
"_id" : "female/alice",
"_key" : "alice",
"_rev" : "_VTxSeym---",
"_oldRev" : "_VTxSeyO---"
},
"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
content-type: application/json; charset=utf-8
etag: _VTxSeym---
x-content-type-options: nosniff
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.
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
content-type: application/json; charset=utf-8
etag: _VTxSfau---
x-content-type-options: nosniff
{
"error" : false,
"vertex" : {
"_id" : "female/alice",
"_key" : "alice",
"_rev" : "_VTxSfau---",
"_oldRev" : "_VTxSfaS---"
},
"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.
Request Body (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
content-type: application/json; charset=utf-8
etag: _VTxSfau---
x-content-type-options: nosniff
{
"error" : false,
"vertex" : {
"_id" : "female/alice",
"_key" : "alice",
"_rev" : "_VTxSfau---",
"_oldRev" : "_VTxSfaS---"
},
"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
content-type: application/json; charset=utf-8
etag: _VTxSfau---
x-content-type-options: nosniff
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
x-content-type-options: nosniff
{
"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
x-content-type-options: nosniff
{
"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
x-content-type-options: nosniff