update document for new api route
diff --git a/doc/source/getting_started/your_first_graph.rst b/doc/source/getting_started/your_first_graph.rst
index 72d6e08..916cf53 100644
--- a/doc/source/getting_started/your_first_graph.rst
+++ b/doc/source/getting_started/your_first_graph.rst
@@ -11,7 +11,7 @@
.. code:: bash
- curl -XPOST localhost:9000/graphs/createService -H 'Content-Type: Application/json' -d '
+ curl -XPOST localhost:9000/admin/createService -H 'Content-Type: Application/json' -d '
{
"serviceName": "KakaoFavorites",
"compressionAlgorithm" : "gz"
@@ -21,7 +21,7 @@
.. code:: bash
- curl -XGET localhost:9000/graphs/getService/KakaoFavorites
+ curl -XGET localhost:9000/admin/getService/KakaoFavorites
Next, we will need some friends.
---------------------------------------------
@@ -29,7 +29,7 @@
.. code:: bash
- curl -XPOST localhost:9000/graphs/createLabel -H 'Content-Type: Application/json' -d '
+ curl -XPOST localhost:9000/admin/createLabel -H 'Content-Type: Application/json' -d '
{
"label": "friends",
"srcServiceName": "KakaoFavorites",
@@ -48,13 +48,13 @@
.. code:: bash
- curl -XGET localhost:9000/graphs/getLabel/friends
+ curl -XGET localhost:9000/admin/getLabel/friends
Now that the label ``friends`` is ready, we can store the friendship data. Entries of a label are called edges, and you can add edges with ``edges/insert`` API:
.. code:: bash
- curl -XPOST localhost:9000/graphs/edges/insert -H 'Content-Type: Application/json' -d '
+ curl -XPOST localhost:9000/mutate/edge/insert -H 'Content-Type: Application/json' -d '
[
{"from":"Elmo","to":"Big Bird","label":"friends","props":{},"timestamp":1444360152477},
{"from":"Elmo","to":"Ernie","label":"friends","props":{},"timestamp":1444360152478},
@@ -95,7 +95,7 @@
.. code:: bash
- curl -XPOST localhost:9000/graphs/createLabel -H 'Content-Type: Application/json' -d '
+ curl -XPOST localhost:9000/admin/createLabel -H 'Content-Type: Application/json' -d '
{
"label": "post",
"srcServiceName": "KakaoFavorites",
@@ -114,7 +114,7 @@
.. code:: bash
- curl -XPOST localhost:9000/graphs/edges/insert -H 'Content-Type: Application/json' -d '
+ curl -XPOST localhost:9000/mutate/edge/insert -H 'Content-Type: Application/json' -d '
[
{"from":"Big Bird","to":"www.kakaocorp.com/en/main","label":"post","props":{},"timestamp":1444360152477},
{"from":"Big Bird","to":"github.com/kakao/s2graph","label":"post","props":{},"timestamp":1444360152478},
diff --git a/s2http/src/main/scala/org/apache/s2graph/http/S2GraphAdminRoute.scala b/s2http/src/main/scala/org/apache/s2graph/http/S2GraphAdminRoute.scala
index 47ac86a..1219968 100644
--- a/s2http/src/main/scala/org/apache/s2graph/http/S2GraphAdminRoute.scala
+++ b/s2http/src/main/scala/org/apache/s2graph/http/S2GraphAdminRoute.scala
@@ -56,27 +56,27 @@
// routes impl
/* GET */
- // GET /graphs/getService/:serviceName
+ // GET /admin/getService/:serviceName
lazy val getService = path("getService" / Segment) { serviceName =>
val serviceOpt = Management.findService(serviceName)
complete(toHttpEntity(serviceOpt, message = s"Service not found: ${serviceName}"))
}
- // GET /graphs/getServiceColumn/:serviceName/:columnName
+ // GET /admin/getServiceColumn/:serviceName/:columnName
lazy val getServiceColumn = path("getServiceColumn" / Segment / Segment) { (serviceName, columnName) =>
val ret = Management.findServiceColumn(serviceName, columnName)
complete(toHttpEntity(ret, message = s"ServiceColumn not found: ${serviceName}, ${columnName}"))
}
- // GET /graphs/getLabel/:labelName
+ // GET /admin/getLabel/:labelName
lazy val getLabel = path("getLabel" / Segment) { labelName =>
val labelOpt = Management.findLabel(labelName)
complete(toHttpEntity(labelOpt, message = s"Label not found: ${labelName}"))
}
- // GET /graphs/getLabels/:serviceName
+ // GET /admin/getLabels/:serviceName
lazy val getLabels = path("getLabels" / Segment) { serviceName =>
val ret = Management.findLabels(serviceName)
@@ -84,7 +84,7 @@
}
/* POST */
- // POST /graphs/createService
+ // POST /admin/createService
lazy val createService = path("createService") {
entity(as[JsValue]) { params =>
@@ -98,7 +98,7 @@
}
}
- // POST /graphs/createServiceColumn
+ // POST /admin/createServiceColumn
lazy val createServiceColumn = path("createServiceColumn") {
entity(as[JsValue]) { params =>
@@ -112,7 +112,7 @@
}
}
- // POST /graphs/createLabel
+ // POST /admin/createLabel
lazy val createLabel = path("createLabel") {
entity(as[JsValue]) { params =>
val labelTry = requestParser.toLabelElements(params)
@@ -133,7 +133,7 @@
}
}
- // POST /graphs/addProp/:labelName
+ // POST /admin/addProp/:labelName
lazy val addProp = path("addProp" / Segment) { labelName =>
entity(as[JsValue]) { params =>
val labelMetaTry = for {
@@ -145,7 +145,7 @@
}
}
- // POST /graphs/addServiceColumnProp/:serviceName/:columnName
+ // POST /admin/addServiceColumnProp/:serviceName/:columnName
lazy val addServiceColumnProp = path("addServiceColumnProp" / Segments) { params =>
val (serviceName, columnName, storeInGlobalIndex) = params match {
case s :: c :: Nil => (s, c, false)
@@ -166,7 +166,7 @@
}
}
- // POST /graphs/createHTable
+ // POST /admin/createHTable
lazy val createHTable = path("createHTable") {
entity(as[JsValue]) { params =>
params.validate[HTableParams] match {
@@ -182,14 +182,14 @@
}
}
- // POST /graphs/copyLabel/:oldLabelName/:newLabelName
+ // POST /admin/copyLabel/:oldLabelName/:newLabelName
lazy val copyLabel = path("copyLabel" / Segment / Segment) { (oldLabelName, newLabelName) =>
val copyTry = management.copyLabel(oldLabelName, newLabelName, Some(newLabelName))
complete(toHttpEntity(copyTry))
}
- // POST /graphs/renameLabel/:oldLabelName/:newLabelName
+ // POST /admin/renameLabel/:oldLabelName/:newLabelName
lazy val renameLabel = path("renameLabel" / Segment / Segment) { (oldLabelName, newLabelName) =>
Label.findByName(oldLabelName) match {
case None => complete(toHttpEntity(None: Option[JsValue], status = StatusCodes.NotFound, message = s"Label $oldLabelName not found."))
@@ -200,7 +200,7 @@
}
}
- // POST /graphs/swapLabels/:leftLabelName/:rightLabelName
+ // POST /admin/swapLabels/:leftLabelName/:rightLabelName
lazy val swapLabel = path("swapLabel" / Segment / Segment) { (leftLabelName, rightLabelName) =>
val left = Label.findByName(leftLabelName, useCache = false)
val right = Label.findByName(rightLabelName, useCache = false)
@@ -215,7 +215,7 @@
}
}
- // POST /graphs/updateHTable/:labelName/:newHTableName
+ // POST /admin/updateHTable/:labelName/:newHTableName
lazy val updateHTable = path("updateHTable" / Segment / Segment) { (labelName, newHTableName) =>
val updateTry = Management.updateHTable(labelName, newHTableName).map(Json.toJson(_))
@@ -223,21 +223,21 @@
}
/* PUT */
- // PUT /graphs/deleteLabelReally/:labelName
+ // PUT /admin/deleteLabelReally/:labelName
lazy val deleteLabelReally = path("deleteLabelReally" / Segment) { labelName =>
val ret = Management.deleteLabel(labelName).toOption
complete(toHttpEntity(ret, message = s"Label not found: ${labelName}"))
}
- // PUT /graphs/markDeletedLabel/:labelName
+ // PUT /admin/markDeletedLabel/:labelName
lazy val markDeletedLabel = path("markDeletedLabel" / Segment) { labelName =>
val ret = Management.markDeletedLabel(labelName).toOption.map(Json.toJson(_))
complete(toHttpEntity(ret, message = s"Label not found: ${labelName}"))
}
- // PUT /graphs/deleteServiceColumn/:serviceName/:columnName
+ // PUT /admin/deleteServiceColumn/:serviceName/:columnName
lazy val deleteServiceColumn = path("deleteServiceColumn" / Segment / Segment) { (serviceName, columnName) =>
val ret = Management.deleteColumn(serviceName, columnName).toOption
diff --git a/s2http/src/main/scala/org/apache/s2graph/http/Server.scala b/s2http/src/main/scala/org/apache/s2graph/http/Server.scala
index 00146f6..03802ed 100644
--- a/s2http/src/main/scala/org/apache/s2graph/http/Server.scala
+++ b/s2http/src/main/scala/org/apache/s2graph/http/Server.scala
@@ -49,7 +49,9 @@
override val logger = LoggerFactory.getLogger(this.getClass)
val port = sys.props.get("http.port").fold(8000)(_.toInt)
- val serverStatus = s""" { "port": ${port}, "started_at": ${System.currentTimeMillis()} }"""
+ val interface = sys.props.get("http.interface").fold("0.0.0.0")(identity)
+
+ val serverStatus = s""" { "port": ${port}, "interface": ${interface}, "started_at": ${System.currentTimeMillis()} }"""
val health = HttpResponse(status = StatusCodes.OK, entity = HttpEntity(ContentTypes.`application/json`, serverStatus))
@@ -62,7 +64,7 @@
get(complete(health))
)
- val binding: Future[Http.ServerBinding] = Http().bindAndHandle(routes, "localhost", port)
+ val binding: Future[Http.ServerBinding] = Http().bindAndHandle(routes, interface, port)
binding.onComplete {
case Success(bound) => logger.info(s"Server online at http://${bound.localAddress.getHostString}:${bound.localAddress.getPort}/")
case Failure(e) => logger.error(s"Server could not start!", e)