From e2b0691e9d6a646ece60695fb170cb0b1e601ffa Mon Sep 17 00:00:00 2001 From: Woonsan Ko Date: Sun, 7 Apr 2019 18:27:49 -0400 Subject: [PATCH 1/5] S2GRAPH-253: adding swagger api-docs route --- s2http/build.sbt | 3 + .../resources/s2http/swagger/index.html | 61 +++++++++++++ .../resources/s2http/swagger/v2/swagger.json | 90 +++++++++++++++++++ .../org/apache/s2graph/http/Server.scala | 19 ++++ 4 files changed, 173 insertions(+) create mode 100644 s2http/src/main/resources/META-INF/resources/s2http/swagger/index.html create mode 100644 s2http/src/main/resources/META-INF/resources/s2http/swagger/v2/swagger.json diff --git a/s2http/build.sbt b/s2http/build.sbt index ef020cd9..c094a6eb 100644 --- a/s2http/build.sbt +++ b/s2http/build.sbt @@ -18,6 +18,7 @@ */ lazy val akkaHttpVersion = "10.1.6" lazy val akkaVersion = "2.5.19" +lazy val swaggerUiWebjarsVersion = "3.20.9" name := "s2http" @@ -32,6 +33,8 @@ libraryDependencies ++= Seq( "com.typesafe.akka" %% "akka-http-spray-json" % akkaHttpVersion, "com.typesafe.akka" %% "akka-stream" % akkaVersion, + "org.webjars" % "swagger-ui" % swaggerUiWebjarsVersion, + "com.typesafe.akka" %% "akka-http-testkit" % akkaHttpVersion % Test, "com.typesafe.akka" %% "akka-stream-testkit" % akkaVersion % Test, diff --git a/s2http/src/main/resources/META-INF/resources/s2http/swagger/index.html b/s2http/src/main/resources/META-INF/resources/s2http/swagger/index.html new file mode 100644 index 00000000..76533826 --- /dev/null +++ b/s2http/src/main/resources/META-INF/resources/s2http/swagger/index.html @@ -0,0 +1,61 @@ + + + + + + + Swagger UI + + + + + + + +
+ + + + + + diff --git a/s2http/src/main/resources/META-INF/resources/s2http/swagger/v2/swagger.json b/s2http/src/main/resources/META-INF/resources/s2http/swagger/v2/swagger.json new file mode 100644 index 00000000..17a5f984 --- /dev/null +++ b/s2http/src/main/resources/META-INF/resources/s2http/swagger/v2/swagger.json @@ -0,0 +1,90 @@ +{ + "swagger":"2.0", + "info":{ + "description":"This is S2Graph HTTP Server.", + "version":"1.0.0", + "title":"S2Graph HTTP Server", + "termsOfService":"http://swagger.io/terms/", + "contact":{ + "email":"apiteam@swagger.io" + }, + "license":{ + "name":"Apache 2.0", + "url":"http://www.apache.org/licenses/LICENSE-2.0.html" + } + }, + "tags":[ + { + "name":"s2graph", + "description":"S2Graph HTTP Server", + "externalDocs":{ + "description":"Find out more about Apache S2Graph", + "url":"http://s2graph.incubator.apache.org/" + } + } + ], + "schemes":[ + "http", + "https" + ], + "paths":{ + "/admin":{ + "post":{ + "tags":[ + "admin" + ], + "summary":"Admin Apis for Management Service, Label, Index ..", + "description":"", + "operationId":"createService", + "consumes":[ + "application/json", + ], + "produces":[ + "application/json" + ], + "parameters":[ + { + "in":"body", + "name":"body", + "description":"Service", + "required":true, + "schema":{ + "$ref":"#/definitions/Service" + } + } + ], + "responses":{ + "405":{ + "description":"Invalid input" + } + } + } + } + }, + "definitions":{ + "Service":{ + "type":"object", + "properties":{ + "serviceName":{ + "type":"string" + }, + "cluster":{ + "type":"string" + }, + "hTableName":{ + "type":"string" + }, + "hTableTTL":{ + "type":"integer" + }, + "preSplitSize":{ + "type":"integer" + } + } + } + }, + "externalDocs":{ + "description":"Find out more about Apache S2Graph", + "url":"http://s2graph.incubator.apache.org/" + } +} 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 e70a1829..2ce8dd34 100644 --- a/s2http/src/main/scala/org/apache/s2graph/http/Server.scala +++ b/s2http/src/main/scala/org/apache/s2graph/http/Server.scala @@ -53,6 +53,10 @@ object Server extends App val port = sys.props.get("http.port").fold(8000)(_.toInt) val interface = sys.props.get("http.interface").fold("0.0.0.0")(identity) + val SwaggerIndexPage = "index.html" + val SwaggerIndexResPath = s"META-INF/resources/s2http/swagger/$SwaggerIndexPage" + val SwaggerWebJarBaseResPath = "META-INF/resources/webjars/swagger-ui/3.20.9/" + val startAt = System.currentTimeMillis() def uptime = System.currentTimeMillis() - startAt @@ -67,6 +71,21 @@ object Server extends App pathPrefix("mutate")(mutateRoute), pathPrefix("admin")(adminRoute), pathPrefix("graphql")(graphqlRoute), + pathPrefix("api-docs") { + pathEnd { + redirect("/api-docs/", StatusCodes.TemporaryRedirect) + } ~ + path(Segments) { segs => { + val resPath = segs.mkString("/") + if (resPath.isEmpty || resPath == SwaggerIndexPage) + getFromResource(SwaggerIndexResPath) + else if (resPath.startsWith("s2http")) + getFromResource("META-INF/resources/" + resPath) + else + getFromResource(SwaggerWebJarBaseResPath + resPath) + } + } + }, get(complete(health)) ) From 89b0724f2989e1b40a53017313d4a6526002fad1 Mon Sep 17 00:00:00 2001 From: Woonsan Ko Date: Mon, 8 Apr 2019 14:20:57 -0400 Subject: [PATCH 2/5] S2GRAPH-253: swagger doc for createService, createLabel and addIndex --- .../resources/s2http/swagger/v2/swagger.json | 422 +++++++++++++++++- 1 file changed, 415 insertions(+), 7 deletions(-) diff --git a/s2http/src/main/resources/META-INF/resources/s2http/swagger/v2/swagger.json b/s2http/src/main/resources/META-INF/resources/s2http/swagger/v2/swagger.json index 17a5f984..dbdd6381 100644 --- a/s2http/src/main/resources/META-INF/resources/s2http/swagger/v2/swagger.json +++ b/s2http/src/main/resources/META-INF/resources/s2http/swagger/v2/swagger.json @@ -2,11 +2,10 @@ "swagger":"2.0", "info":{ "description":"This is S2Graph HTTP Server.", - "version":"1.0.0", + "version":"0.2", "title":"S2Graph HTTP Server", - "termsOfService":"http://swagger.io/terms/", "contact":{ - "email":"apiteam@swagger.io" + "email":"dev@s2graph.incubator.apache.org" }, "license":{ "name":"Apache 2.0", @@ -28,12 +27,12 @@ "https" ], "paths":{ - "/admin":{ + "/admin/createService":{ "post":{ "tags":[ "admin" ], - "summary":"Admin Apis for Management Service, Label, Index ..", + "summary":"Create a service", "description":"", "operationId":"createService", "consumes":[ @@ -54,8 +53,90 @@ } ], "responses":{ - "405":{ - "description":"Invalid input" + "201": { + "description":"Successfully created", + "schema":{ + "$ref":"#/definitions/ServiceResponse" + } + }, + "400":{ + "description": "Bad request" + } + } + } + }, + "/admin/createLabel":{ + "post":{ + "tags":[ + "admin" + ], + "summary":"Create a label", + "description":"", + "operationId":"createLabel", + "consumes":[ + "application/json", + ], + "produces":[ + "application/json" + ], + "parameters":[ + { + "in":"body", + "name":"body", + "description":"Service", + "required":true, + "schema":{ + "$ref":"#/definitions/Label" + } + } + ], + "responses":{ + "201":{ + "description":"Successful operation", + "schema":{ + "$ref":"#/definitions/LabelResponse" + } + }, + "400":{ + "description": "Bad request" + } + } + } + }, + "/admin/addIndex":{ + "post":{ + "tags":[ + "admin" + ], + "summary":"Add indices to a label", + "description":"", + "operationId":"addIndex", + "consumes":[ + "application/json", + ], + "produces":[ + "application/json" + ], + "parameters":[ + { + "in":"body", + "name":"body", + "description":"Service", + "required":true, + "schema":{ + "$ref":"#/definitions/LabelIndexAddition" + } + } + ], + "responses":{ + "200":{ + "description":"Successful operation", + "schema":{ + "$ref":"#/definitions/LabelIndexAddition" + } + }, + "400":{ + "description": "Bad request" } } } @@ -64,23 +145,350 @@ "definitions":{ "Service":{ "type":"object", + "required": [ + "serviceName" + ], "properties":{ "serviceName":{ + "description": "User defined namespace", + "type":"string" + }, + "cluster":{ + "description": "Zookeeper quorum address", + "type":"string" + }, + "hTableName":{ + "description": "HBase table name", + "type":"string" + }, + "hTableTTL":{ + "description": "Time to live setting for data", + "type":"integer" + }, + "preSplitSize":{ + "description": "Factor for the table pre-split size", + "type":"integer" + } + } + }, + "Label":{ + "type":"object", + "required": [ + "label", + "srcServiceName", + "srcColumnName", + "srcColumnType", + "tgtColumnName", + "tgtColumnType" + ], + "properties":{ + "label":{ + "description": "Name of the relation", + "type":"string" + }, + "srcServiceName":{ + "description": "Source column’s service", + "type":"string" + }, + "srcColumnName":{ + "description": "Source column’s name", + "type":"string" + }, + "srcColumnType":{ + "description": "Source column’s data type", + "type":"string", + "enum": [ + "long", + "integer", + "string" + ] + }, + "tgtServiceName":{ + "description": "Target column’s service", + "type":"string" + }, + "tgtColumnName":{ + "description": "Target column’s name", + "type":"string" + }, + "tgtColumnType":{ + "description": "Target column’s data type", + "type":"string", + "enum": [ + "long", + "integer", + "string" + ] + }, + "indices": { + "description": "Index definitions on the label", + "type": "array", + "items": { + "schema":{ + "$ref":"#/definitions/LabelIndexDefinition" + } + } + }, + "props": { + "description": "Property definitions on the label", + "type": "array", + "items": { + "schema":{ + "$ref":"#/definitions/LabelPropertyDefinition" + } + } + }, + "isDirected":{ + "description": "Wether the label is directed or undirected", + "type":"integer" + }, + "serviceName":{ + "description": "Which service the label belongs to", + "type":"string" + }, + "hTableName":{ + "description": "A dedicated HBase table to your Label", + "type":"string" + }, + "hTableTTL":{ + "description": "Data time to live setting", + "type":"integer" + }, + "consistencyLevel":{ + "description": "If set to ‘strong’, only one edge is alowed between a pair of source/ target vertices. Set to ‘weak’, and multiple-edge is supported", + "type":"string", + "enum": [ + "weak", + "strong" + ] + } + } + }, + "LabelIndexAddition":{ + "type":"object", + "required": [ + "label", + ], + "properties":{ + "label":{ + "description": "Name of the relation", + "type":"string" + }, + "indices": { + "description": "Index definitions on the label", + "type": "array", + "items": { + "schema":{ + "$ref":"#/definitions/LabelIndexDefinition" + } + } + } + } + }, + "LabelIndexDefinition":{ + "type":"object", + "required": [ + "name", + "propNames" + ], + "properties":{ + "name":{ + "description": "Label index name", + "type":"string" + }, + "propNames":{ + "description": "Label property names used by the index", + "type":"array", + "items": { + "type": "string" + } + }, + "dir":{ + "type":"string" + }, + "options":{ + "type":"string" + } + } + }, + "LabelPropertyDefinition":{ + "type":"object", + "required": [ + "name", + "dataType" + ], + "properties":{ + "name":{ + "description": "Label property name", + "type":"string" + }, + "dataType":{ + "description": "Data type of the label property", + "type":"string" + }, + "defaultValue":{ + "description": "Default value of the label property", + "type":"string" + } + } + }, + "ServiceResponse": { + "type":"object", + "required": [ + "status" + ], + "properties":{ + "status":{ + "description": "Status", + "type":"string" + }, + "messasge":{ + "schema":{ + "$ref":"#/definitions/ServiceResponseMessage" + } + } + } + }, + "ServiceResponseMessage": { + "type":"object", + "required": [ + "id", + "name" + ], + "properties":{ + "id":{ + "description": "Message ID", + "type":"string" + }, + "name":{ + "description": "User defined namespace", + "type":"string" + }, + "accessToken":{ + "description": "Access token", "type":"string" }, "cluster":{ + "description": "Zookeeper quorum address", "type":"string" }, "hTableName":{ + "description": "HBase table name", "type":"string" }, "hTableTTL":{ + "description": "Time to live setting for data", "type":"integer" }, "preSplitSize":{ + "description": "Factor for the table pre-split size", "type":"integer" } } + }, + "LabelResponse": { + "type":"object", + "required": [ + "status" + ], + "properties":{ + "status":{ + "description": "Status", + "type":"string" + }, + "messasge":{ + "schema":{ + "$ref":"#/definitions/LabelResponseMessage" + } + } + } + }, + "LabelResponseMessage": { + "type":"object", + "required": [ + "labelName" + ], + "properties":{ + "labelName":{ + "description": "The label name", + "type":"string" + }, + "from":{ + "schema": { + "$ref":"#/definitions/LabelColumn" + } + }, + "to":{ + "schema": { + "$ref":"#/definitions/LabelColumn" + } + }, + "isDirected":{ + "type":"boolean" + }, + "serviceName":{ + "description": "User defined namespace", + "type":"string" + }, + "consistencyLevel":{ + "description": "If set to ‘strong’, only one edge is alowed between a pair of source/ target vertices. Set to ‘weak’, and multiple-edge is supported", + "type":"string", + "enum": [ + "weak", + "strong" + ] + }, + "schemaVersion":{ + "type":"string" + }, + "isAsync":{ + "type":"boolean" + }, + "compressionAlgorithm":{ + "type":"string" + }, + "defaultIndex":{ + "schema": { + "$ref":"#/definitions/LabelIndexDefinition" + } + }, + "extraIndex":{ + "type":"array", + "items":{ + "schema": { + "$ref":"#/definitions/LabelIndexDefinition" + } + } + }, + "metaProps":{ + "type":"array", + "items":{ + "schema": { + "$ref":"#/definitions/LabelPropertyDefinition" + } + } + }, + "options":{ + "type":"string" + } + } + }, + "LabelColumn": { + "type": "object", + "properties": { + "from": { + "type":"string" + }, + "serviceName": { + "type":"string" + }, + "columnName": { + "type":"string" + }, + "columnType": { + "type":"string" + } + } } }, "externalDocs":{ From 42d9325af76bd9f28a986c79411b5dec1c289c61 Mon Sep 17 00:00:00 2001 From: Woonsan Ko Date: Mon, 8 Apr 2019 18:40:53 -0400 Subject: [PATCH 3/5] S2GRAPH-253: add getLabel and more polishments --- .../resources/s2http/swagger/v2/swagger.json | 230 +++++++++++++++--- 1 file changed, 193 insertions(+), 37 deletions(-) diff --git a/s2http/src/main/resources/META-INF/resources/s2http/swagger/v2/swagger.json b/s2http/src/main/resources/META-INF/resources/s2http/swagger/v2/swagger.json index dbdd6381..f872f94d 100644 --- a/s2http/src/main/resources/META-INF/resources/s2http/swagger/v2/swagger.json +++ b/s2http/src/main/resources/META-INF/resources/s2http/swagger/v2/swagger.json @@ -121,18 +121,173 @@ { "in":"body", "name":"body", - "description":"Service", + "description":"Label indices to add", "required":true, "schema":{ - "$ref":"#/definitions/LabelIndexAddition" + "$ref":"#/definitions/LabelIndices" + } + } + ], + "responses":{ + "201":{ + "description":"Successful operation", + "schema":{ + "$ref":"#/definitions/LabelResponse" } + }, + "400":{ + "description": "Bad request" + } + } + } + }, + "/admin/getLabel/{name}":{ + "get":{ + "tags":[ + "admin" + ], + "summary":"Get general information on a label", + "description":"", + "operationId":"getLabelByName", + "consumes":[ + "application/json", + ], + "produces":[ + "application/json" + ], + "parameters":[ + { + "in":"path", + "name":"name", + "description":"Label name", + "required":true, + "type":"string" + } + ], + "responses":{ + "200":{ + "description":"Successful operation", + "schema":{ + "$ref":"#/definitions/LabelResponse" + } + }, + "400":{ + "description": "Bad request" + } + } + } + }, + "/admin/deleteLabel/{name}":{ + "put":{ + "tags":[ + "admin" + ], + "summary":"Delete a label", + "description":"", + "operationId":"deleteLabelByName", + "consumes":[ + "application/json", + ], + "produces":[ + "application/json" + ], + "parameters":[ + { + "in":"path", + "name":"name", + "description":"Label name", + "required":true, + "type":"string" } ], "responses":{ "200":{ "description":"Successful operation", "schema":{ - "$ref":"#/definitions/LabelIndexAddition" + "$ref":"#/definitions/LabelResponse" + } + }, + "400":{ + "description": "Bad request" + } + } + } + }, + "/admin/addProp/{name}":{ + "put":{ + "tags":[ + "admin" + ], + "summary":"Add a new property to the label", + "description":"", + "operationId":"addPropToLabel", + "consumes":[ + "application/json", + ], + "produces":[ + "application/json" + ], + "parameters":[ + { + "in":"path", + "name":"name", + "description":"Label name", + "required":true, + "type":"string" + }, + { + "in":"body", + "name":"body", + "description":"Property definition", + "required":true, + "schema":{ + "$ref":"#/definitions/PropertyDefinition" + } + } + ], + "responses":{ + "201":{ + "description":"Successful operation", + "schema":{ + "$ref":"#/definitions/LabelResponse" + } + }, + "400":{ + "description": "Bad request" + } + } + } + }, + "/admin/createServiceColumn":{ + "put":{ + "tags":[ + "admin" + ], + "summary":"Add a new property to the label", + "description":"", + "operationId":"addPropToLabel", + "consumes":[ + "application/json", + ], + "produces":[ + "application/json" + ], + "parameters":[ + { + "in":"body", + "name":"body", + "description":"Service column definition", + "required":true, + "schema":{ + "$ref":"#/definitions/ServiceColumn" + } + } + ], + "responses":{ + "201":{ + "description":"Successful operation", + "schema":{ + "$ref":"#/definitions/LabelResponse" } }, "400":{ @@ -224,18 +379,14 @@ "description": "Index definitions on the label", "type": "array", "items": { - "schema":{ - "$ref":"#/definitions/LabelIndexDefinition" - } + "$ref":"#/definitions/IndexDefinition" } }, "props": { "description": "Property definitions on the label", "type": "array", "items": { - "schema":{ - "$ref":"#/definitions/LabelPropertyDefinition" - } + "$ref":"#/definitions/PropertyDefinition" } }, "isDirected":{ @@ -264,7 +415,7 @@ } } }, - "LabelIndexAddition":{ + "LabelIndices":{ "type":"object", "required": [ "label", @@ -278,14 +429,12 @@ "description": "Index definitions on the label", "type": "array", "items": { - "schema":{ - "$ref":"#/definitions/LabelIndexDefinition" - } + "$ref":"#/definitions/IndexDefinition" } } } }, - "LabelIndexDefinition":{ + "IndexDefinition":{ "type":"object", "required": [ "name", @@ -311,7 +460,7 @@ } } }, - "LabelPropertyDefinition":{ + "PropertyDefinition":{ "type":"object", "required": [ "name", @@ -343,9 +492,7 @@ "type":"string" }, "messasge":{ - "schema":{ - "$ref":"#/definitions/ServiceResponseMessage" - } + "$ref":"#/definitions/ServiceResponseMessage" } } }, @@ -397,9 +544,7 @@ "type":"string" }, "messasge":{ - "schema":{ - "$ref":"#/definitions/LabelResponseMessage" - } + "$ref":"#/definitions/LabelResponseMessage" } } }, @@ -414,14 +559,10 @@ "type":"string" }, "from":{ - "schema": { - "$ref":"#/definitions/LabelColumn" - } + "$ref":"#/definitions/ServiceLabelColumn" }, "to":{ - "schema": { - "$ref":"#/definitions/LabelColumn" - } + "$ref":"#/definitions/ServiceLabelColumn" }, "isDirected":{ "type":"boolean" @@ -448,24 +589,18 @@ "type":"string" }, "defaultIndex":{ - "schema": { - "$ref":"#/definitions/LabelIndexDefinition" - } + "$ref":"#/definitions/IndexDefinition" }, "extraIndex":{ "type":"array", "items":{ - "schema": { - "$ref":"#/definitions/LabelIndexDefinition" - } + "$ref":"#/definitions/IndexDefinition" } }, "metaProps":{ "type":"array", "items":{ - "schema": { - "$ref":"#/definitions/LabelPropertyDefinition" - } + "$ref":"#/definitions/PropertyDefinition" } }, "options":{ @@ -473,7 +608,28 @@ } } }, - "LabelColumn": { + "ServiceColumn": { + "type": "object", + "properties": { + "serviceName": { + "type":"string" + }, + "columnName": { + "type":"string" + }, + "columnType": { + "type":"string" + }, + "props": { + "description": "Property definitions", + "type": "array", + "items": { + "$ref":"#/definitions/PropertyDefinition" + } + } + } + }, + "ServiceLabelColumn": { "type": "object", "properties": { "from": { From b2f017419ef2150f24d3848b9ba2391ffbc6db82 Mon Sep 17 00:00:00 2001 From: Woonsan Ko Date: Tue, 9 Apr 2019 19:09:43 -0400 Subject: [PATCH 4/5] S2GRAPH-253: adding more api docs; rename deleteLabel to deleteLabelReally --- .../resources/s2http/swagger/index.html | 19 +- .../resources/s2http/swagger/v0/swagger.json | 1273 +++++++++++++++++ .../resources/s2http/swagger/v2/swagger.json | 654 --------- 3 files changed, 1290 insertions(+), 656 deletions(-) create mode 100644 s2http/src/main/resources/META-INF/resources/s2http/swagger/v0/swagger.json delete mode 100644 s2http/src/main/resources/META-INF/resources/s2http/swagger/v2/swagger.json diff --git a/s2http/src/main/resources/META-INF/resources/s2http/swagger/index.html b/s2http/src/main/resources/META-INF/resources/s2http/swagger/index.html index 76533826..68592576 100644 --- a/s2http/src/main/resources/META-INF/resources/s2http/swagger/index.html +++ b/s2http/src/main/resources/META-INF/resources/s2http/swagger/index.html @@ -1,4 +1,19 @@ - + @@ -40,7 +55,7 @@ window.onload = function() { // Begin Swagger UI call region const ui = SwaggerUIBundle({ - url: "/api-docs/s2http/swagger/v2/swagger.json", + url: "/api-docs/s2http/swagger/v0/swagger.json", dom_id: '#swagger-ui', deepLinking: true, presets: [ diff --git a/s2http/src/main/resources/META-INF/resources/s2http/swagger/v0/swagger.json b/s2http/src/main/resources/META-INF/resources/s2http/swagger/v0/swagger.json new file mode 100644 index 00000000..62aadea0 --- /dev/null +++ b/s2http/src/main/resources/META-INF/resources/s2http/swagger/v0/swagger.json @@ -0,0 +1,1273 @@ +{ + "swagger":"2.0", + "info":{ + "description":"This is S2Graph HTTP Server.", + "version":"0.2", + "title":"S2Graph HTTP Server", + "contact":{ + "email":"dev@s2graph.incubator.apache.org" + }, + "license":{ + "name":"Apache 2.0", + "url":"http://www.apache.org/licenses/LICENSE-2.0.html" + } + }, + "tags":[ + { + "name":"s2graph", + "description":"S2Graph HTTP Server", + "externalDocs":{ + "description":"Find out more about Apache S2Graph", + "url":"http://s2graph.incubator.apache.org/" + } + } + ], + "schemes":[ + "http", + "https" + ], + "paths":{ + "/admin/createService":{ + "post":{ + "tags":[ + "admin" + ], + "summary":"Create a service", + "description":"", + "operationId":"createService", + "consumes":[ + "application/json" + ], + "produces":[ + "application/json" + ], + "parameters":[ + { + "in":"body", + "name":"body", + "description":"Service", + "required":true, + "schema":{ + "$ref":"#/definitions/Service" + } + } + ], + "responses":{ + "201":{ + "description":"Successfully created", + "schema":{ + "$ref":"#/definitions/ServiceResponse" + } + }, + "400":{ + "description":"Bad request" + } + } + } + }, + "/admin/createLabel":{ + "post":{ + "tags":[ + "admin" + ], + "summary":"Create a label", + "description":"", + "operationId":"createLabel", + "consumes":[ + "application/json" + ], + "produces":[ + "application/json" + ], + "parameters":[ + { + "in":"body", + "name":"body", + "description":"Service", + "required":true, + "schema":{ + "$ref":"#/definitions/Label" + } + } + ], + "responses":{ + "201":{ + "description":"Successful operation", + "schema":{ + "$ref":"#/definitions/LabelResponse" + } + }, + "400":{ + "description":"Bad request" + } + } + } + }, + "/admin/addIndex":{ + "post":{ + "tags":[ + "admin" + ], + "summary":"Add indices to a label", + "description":"", + "operationId":"addIndex", + "consumes":[ + "application/json" + ], + "produces":[ + "application/json" + ], + "parameters":[ + { + "in":"body", + "name":"body", + "description":"Label indices to add", + "required":true, + "schema":{ + "$ref":"#/definitions/LabelIndices" + } + } + ], + "responses":{ + "201":{ + "description":"Successful operation", + "schema":{ + "$ref":"#/definitions/LabelResponse" + } + }, + "400":{ + "description":"Bad request" + } + } + } + }, + "/admin/getLabel/{name}":{ + "get":{ + "tags":[ + "admin" + ], + "summary":"Get general information on a label", + "description":"", + "operationId":"getLabelByName", + "consumes":[ + "application/json" + ], + "produces":[ + "application/json" + ], + "parameters":[ + { + "in":"path", + "name":"name", + "description":"Label name", + "required":true, + "type":"string" + } + ], + "responses":{ + "200":{ + "description":"Successful operation", + "schema":{ + "$ref":"#/definitions/LabelResponse" + } + }, + "400":{ + "description":"Bad request" + } + } + } + }, + "/admin/deleteLabelReally/{name}":{ + "put":{ + "tags":[ + "admin" + ], + "summary":"Delete a label", + "description":"", + "operationId":"deleteLabelByName", + "consumes":[ + "application/json" + ], + "produces":[ + "application/json" + ], + "parameters":[ + { + "in":"path", + "name":"name", + "description":"Label name", + "required":true, + "type":"string" + } + ], + "responses":{ + "200":{ + "description":"Successful operation", + "schema":{ + "$ref":"#/definitions/Label" + } + }, + "400":{ + "description":"Bad request" + } + } + } + }, + "/admin/addProp/{name}":{ + "post":{ + "tags":[ + "admin" + ], + "summary":"Add a new property to the label", + "description":"", + "operationId":"addPropToLabel", + "consumes":[ + "application/json" + ], + "produces":[ + "application/json" + ], + "parameters":[ + { + "in":"path", + "name":"name", + "description":"Label name", + "required":true, + "type":"string" + }, + { + "in":"body", + "name":"body", + "description":"Property definition", + "required":true, + "schema":{ + "$ref":"#/definitions/PropertyDefinition" + } + } + ], + "responses":{ + "201":{ + "description":"Successful operation", + "schema":{ + "$ref":"#/definitions/LabelResponse" + } + }, + "400":{ + "description":"Bad request" + } + } + } + }, + "/admin/createServiceColumn":{ + "post":{ + "tags":[ + "admin" + ], + "summary":"Add a new property to the label", + "description":"", + "operationId":"createServiceColumn", + "consumes":[ + "application/json" + ], + "produces":[ + "application/json" + ], + "parameters":[ + { + "in":"body", + "name":"body", + "description":"Service column definition", + "required":true, + "schema":{ + "$ref":"#/definitions/ServiceColumn" + } + } + ], + "responses":{ + "201":{ + "description":"Successful operation", + "schema":{ + "$ref":"#/definitions/LabelResponse" + } + }, + "400":{ + "description":"Bad request" + } + } + } + }, + "/mutate/vertex/insert/{service}/{column}":{ + "post":{ + "tags":[ + "mutate" + ], + "summary":"Create new vertices.", + "description":"", + "operationId":"insertVertices", + "consumes":[ + "application/json" + ], + "produces":[ + "application/json" + ], + "parameters":[ + { + "in":"path", + "name":"service", + "description":"Service name.", + "required":true, + "type":"string" + }, + { + "in":"path", + "name":"column", + "description":"Column name.", + "required":true, + "type":"string" + }, + { + "in":"body", + "name":"body", + "description":"Request to get edges.", + "required":true, + "schema":{ + "$ref":"#/definitions/VerticesRequest" + } + } + ], + "responses":{ + "201":{ + "description":"Successful operation", + "schema":{ + "$ref":"#/definitions/VerticesResponse" + } + }, + "400":{ + "description":"Bad request" + } + } + } + }, + "/mutate/vertex/delete/{service}/{column}":{ + "post":{ + "tags":[ + "mutate" + ], + "summary":"Delete vertices.", + "description":"", + "operationId":"deleteVertices", + "consumes":[ + "application/json" + ], + "produces":[ + "application/json" + ], + "parameters":[ + { + "in":"path", + "name":"service", + "description":"Service name.", + "required":true, + "type":"string" + }, + { + "in":"path", + "name":"column", + "description":"Column name.", + "required":true, + "type":"string" + }, + { + "in":"body", + "name":"body", + "description":"Request to get edges.", + "required":true, + "schema":{ + "$ref":"#/definitions/VerticesRequest" + } + } + ], + "responses":{ + "200":{ + "description":"Successful operation", + "schema":{ + "$ref":"#/definitions/VerticesResponse" + } + }, + "400":{ + "description":"Bad request" + } + } + } + }, + "/mutate/vertex/deleteAll/{service}/{column}":{ + "post":{ + "tags":[ + "mutate" + ], + "summary":"Delete all vertices.", + "description":"", + "operationId":"deleteAllVertices", + "consumes":[ + "application/json" + ], + "produces":[ + "application/json" + ], + "parameters":[ + { + "in":"path", + "name":"service", + "description":"Service name.", + "required":true, + "type":"string" + }, + { + "in":"path", + "name":"column", + "description":"Column name.", + "required":true, + "type":"string" + }, + { + "in":"body", + "name":"body", + "description":"Request to get edges.", + "required":true, + "schema":{ + "$ref":"#/definitions/VerticesRequest" + } + } + ], + "responses":{ + "200":{ + "description":"Successful operation", + "schema":{ + "$ref":"#/definitions/VerticesResponse" + } + }, + "400":{ + "description":"Bad request" + } + } + } + }, + "/mutate/edge/insert":{ + "post":{ + "tags":[ + "mutate" + ], + "summary":"Create new edges.", + "description":"", + "operationId":"insertEdges", + "consumes":[ + "application/json" + ], + "produces":[ + "application/json" + ], + "parameters":[ + { + "in":"body", + "name":"body", + "description":"Request to get edges.", + "required":true, + "schema":{ + "$ref":"#/definitions/EdgesRequest" + } + } + ], + "responses":{ + "201":{ + "description":"Successful operation", + "schema":{ + "$ref":"#/definitions/EdgesResponse" + } + }, + "400":{ + "description":"Bad request" + } + } + } + }, + "/mutate/edge/delete":{ + "post":{ + "tags":[ + "mutate" + ], + "summary":"Delete edges.", + "description":"", + "operationId":"deleteEdges", + "consumes":[ + "application/json" + ], + "produces":[ + "application/json" + ], + "parameters":[ + { + "in":"body", + "name":"body", + "description":"Request to get edges.", + "required":true, + "schema":{ + "$ref":"#/definitions/EdgesRequest" + } + } + ], + "responses":{ + "201":{ + "description":"Successful operation", + "schema":{ + "$ref":"#/definitions/EdgesResponse" + } + }, + "400":{ + "description":"Bad request" + } + } + } + }, + "/mutate/edge/update":{ + "post":{ + "tags":[ + "mutate" + ], + "summary":"Update edges.", + "description":"", + "operationId":"updateEdges", + "consumes":[ + "application/json" + ], + "produces":[ + "application/json" + ], + "parameters":[ + { + "in":"body", + "name":"body", + "description":"Request to get edges.", + "required":true, + "schema":{ + "$ref":"#/definitions/EdgesRequest" + } + } + ], + "responses":{ + "201":{ + "description":"Successful operation", + "schema":{ + "$ref":"#/definitions/EdgesResponse" + } + }, + "400":{ + "description":"Bad request" + } + } + } + }, + "/mutate/edge/increment":{ + "post":{ + "tags":[ + "mutate" + ], + "summary":"Return edges with incremented values", + "description":"Works like update, other than it returns the incremented value and not the old value.", + "operationId":"incrementEdges", + "consumes":[ + "application/json" + ], + "produces":[ + "application/json" + ], + "parameters":[ + { + "in":"body", + "name":"body", + "description":"Request to get edges.", + "required":true, + "schema":{ + "$ref":"#/definitions/EdgesRequest" + } + } + ], + "responses":{ + "201":{ + "description":"Successful operation", + "schema":{ + "$ref":"#/definitions/EdgesResponse" + } + }, + "400":{ + "description":"Bad request" + } + } + } + }, + "/mutate/edge/deleteAll":{ + "post":{ + "tags":[ + "mutate" + ], + "summary":"Delete all edges.", + "description":"", + "operationId":"deleteAllEdges", + "consumes":[ + "application/json" + ], + "produces":[ + "application/json" + ], + "parameters":[ + { + "in":"body", + "name":"body", + "description":"Request to get edges.", + "required":true, + "schema":{ + "$ref":"#/definitions/EdgesRequest" + } + } + ], + "responses":{ + "201":{ + "description":"Successful operation", + "schema":{ + "$ref":"#/definitions/EdgesResponse" + } + }, + "400":{ + "description":"Bad request" + } + } + } + }, + "/graphs/getVertices":{ + "post":{ + "tags":[ + "query" + ], + "summary":"Select vertices.", + "description":"", + "operationId":"getVertices", + "consumes":[ + "application/json" + ], + "produces":[ + "application/json" + ], + "parameters":[ + { + "in":"body", + "name":"body", + "description":"Request to get vertices.", + "required":true, + "schema":{ + "$ref":"#/definitions/VerticesRequest" + } + } + ], + "responses":{ + "200":{ + "description":"Successful operation", + "schema":{ + "$ref":"#/definitions/VerticesResponse" + } + }, + "400":{ + "description":"Bad request" + } + } + } + }, + "/graphs/checkEdges":{ + "post":{ + "tags":[ + "query" + ], + "summary":"Return edge for given vertex pair only if edge exist.", + "description":"This is more general way to check edge existence between any given vertex pairs comparing using _to on query parameter.", + "operationId":"checkEdges", + "consumes":[ + "application/json" + ], + "produces":[ + "application/json" + ], + "parameters":[ + { + "in":"body", + "name":"body", + "description":"Request to get edges.", + "required":true, + "schema":{ + "$ref":"#/definitions/EdgesRequest" + } + } + ], + "responses":{ + "200":{ + "description":"Successful operation", + "schema":{ + "$ref":"#/definitions/EdgesResponse" + } + }, + "400":{ + "description":"Bad request" + } + } + } + }, + "/graphs/getEdges":{ + "post":{ + "tags":[ + "query" + ], + "summary":"Select edges.", + "description":"", + "operationId":"getEdges", + "consumes":[ + "application/json" + ], + "produces":[ + "application/json" + ], + "parameters":[ + { + "in":"body", + "name":"body", + "description":"Request to get edges.", + "required":true, + "schema":{ + "$ref":"#/definitions/EdgesRequest" + } + } + ], + "responses":{ + "200":{ + "description":"Successful operation", + "schema":{ + "$ref":"#/definitions/EdgesResponse" + } + }, + "400":{ + "description":"Bad request" + } + } + } + } + }, + "definitions":{ + "Service":{ + "type":"object", + "required":[ + "serviceName" + ], + "properties":{ + "serviceName":{ + "description":"User defined namespace", + "type":"string" + }, + "cluster":{ + "description":"Zookeeper quorum address", + "type":"string" + }, + "hTableName":{ + "description":"HBase table name", + "type":"string" + }, + "hTableTTL":{ + "description":"Time to live setting for data", + "type":"integer" + }, + "preSplitSize":{ + "description":"Factor for the table pre-split size", + "type":"integer" + } + } + }, + "Label":{ + "type":"object", + "required":[ + "label", + "srcServiceName", + "srcColumnName", + "srcColumnType", + "tgtColumnName", + "tgtColumnType" + ], + "properties":{ + "label":{ + "description":"Name of the relation", + "type":"string" + }, + "srcServiceName":{ + "description":"Source column’s service", + "type":"string" + }, + "srcColumnName":{ + "description":"Source column’s name", + "type":"string" + }, + "srcColumnType":{ + "description":"Source column’s data type", + "type":"string", + "enum":[ + "long", + "integer", + "string" + ] + }, + "tgtServiceName":{ + "description":"Target column’s service", + "type":"string" + }, + "tgtColumnName":{ + "description":"Target column’s name", + "type":"string" + }, + "tgtColumnType":{ + "description":"Target column’s data type", + "type":"string", + "enum":[ + "long", + "integer", + "string" + ] + }, + "indices":{ + "description":"Index definitions on the label", + "type":"array", + "items":{ + "$ref":"#/definitions/IndexDefinition" + } + }, + "props":{ + "description":"Property definitions on the label", + "type":"array", + "items":{ + "$ref":"#/definitions/PropertyDefinition" + } + }, + "isDirected":{ + "description":"Wether the label is directed or undirected", + "type":"integer" + }, + "serviceName":{ + "description":"Which service the label belongs to", + "type":"string" + }, + "hTableName":{ + "description":"A dedicated HBase table to your Label", + "type":"string" + }, + "hTableTTL":{ + "description":"Data time to live setting", + "type":"integer" + }, + "consistencyLevel":{ + "description":"If set to ‘strong’, only one edge is alowed between a pair of source/ target vertices. Set to ‘weak’, and multiple-edge is supported", + "type":"string", + "enum":[ + "weak", + "strong" + ] + } + } + }, + "LabelIndices":{ + "type":"object", + "required":[ + "label" + ], + "properties":{ + "label":{ + "description":"Name of the relation", + "type":"string" + }, + "indices":{ + "description":"Index definitions on the label", + "type":"array", + "items":{ + "$ref":"#/definitions/IndexDefinition" + } + } + } + }, + "IndexDefinition":{ + "type":"object", + "required":[ + "name", + "propNames" + ], + "properties":{ + "name":{ + "description":"Label index name", + "type":"string" + }, + "propNames":{ + "description":"Label property names used by the index", + "type":"array", + "items":{ + "type":"string" + } + }, + "dir":{ + "type":"string" + }, + "options":{ + "type":"string" + } + } + }, + "PropertyDefinition":{ + "type":"object", + "required":[ + "name", + "dataType" + ], + "properties":{ + "name":{ + "description":"Label property name", + "type":"string" + }, + "dataType":{ + "description":"Data type of the label property", + "type":"string" + }, + "defaultValue":{ + "description":"Default value of the label property", + "type":"string" + } + } + }, + "ServiceResponse":{ + "type":"object", + "required":[ + "status" + ], + "properties":{ + "status":{ + "description":"Status", + "type":"string" + }, + "messasge":{ + "$ref":"#/definitions/ServiceResponseMessage" + } + } + }, + "ServiceResponseMessage":{ + "type":"object", + "required":[ + "id", + "name" + ], + "properties":{ + "id":{ + "description":"Message ID", + "type":"string" + }, + "name":{ + "description":"User defined namespace", + "type":"string" + }, + "accessToken":{ + "description":"Access token", + "type":"string" + }, + "cluster":{ + "description":"Zookeeper quorum address", + "type":"string" + }, + "hTableName":{ + "description":"HBase table name", + "type":"string" + }, + "hTableTTL":{ + "description":"Time to live setting for data", + "type":"integer" + }, + "preSplitSize":{ + "description":"Factor for the table pre-split size", + "type":"integer" + } + } + }, + "LabelResponse":{ + "type":"object", + "required":[ + "status" + ], + "properties":{ + "status":{ + "description":"Status", + "type":"string" + }, + "messasge":{ + "$ref":"#/definitions/LabelResponseMessage" + } + } + }, + "LabelResponseMessage":{ + "type":"object", + "required":[ + "labelName" + ], + "properties":{ + "labelName":{ + "description":"The label name", + "type":"string" + }, + "from":{ + "$ref":"#/definitions/ServiceLabelColumn" + }, + "to":{ + "$ref":"#/definitions/ServiceLabelColumn" + }, + "isDirected":{ + "type":"boolean" + }, + "serviceName":{ + "description":"User defined namespace", + "type":"string" + }, + "consistencyLevel":{ + "description":"If set to ‘strong’, only one edge is alowed between a pair of source/ target vertices. Set to ‘weak’, and multiple-edge is supported", + "type":"string", + "enum":[ + "weak", + "strong" + ] + }, + "schemaVersion":{ + "type":"string" + }, + "isAsync":{ + "type":"boolean" + }, + "compressionAlgorithm":{ + "type":"string" + }, + "defaultIndex":{ + "$ref":"#/definitions/IndexDefinition" + }, + "extraIndex":{ + "type":"array", + "items":{ + "$ref":"#/definitions/IndexDefinition" + } + }, + "metaProps":{ + "type":"array", + "items":{ + "$ref":"#/definitions/PropertyDefinition" + } + }, + "options":{ + "type":"string" + } + } + }, + "ServiceColumn":{ + "type":"object", + "properties":{ + "serviceName":{ + "type":"string" + }, + "columnName":{ + "type":"string" + }, + "columnType":{ + "type":"string" + }, + "props":{ + "description":"Property definitions", + "type":"array", + "items":{ + "$ref":"#/definitions/PropertyDefinition" + } + } + } + }, + "ServiceLabelColumn":{ + "type":"object", + "properties":{ + "from":{ + "type":"string" + }, + "serviceName":{ + "type":"string" + }, + "columnName":{ + "type":"string" + }, + "columnType":{ + "type":"string" + } + } + }, + "VerticesRequest":{ + "type":"array", + "items":{ + "$ref":"#/definitions/Vertex" + } + }, + "VerticesResponse":{ + "type":"object", + "properties":{ + "size":{ + "type":"integer" + }, + "degrees":{ + "type":"array", + "items":{ + } + }, + "results":{ + "type":"array", + "items":{ + "$ref":"#/definitions/Vertex" + } + }, + "impressionId":{ + "type":"integer" + } + } + }, + "EdgesRequest":{ + "type":"object", + "properties":{ + "srcVertices":{ + "type":"array", + "items":{ + "$ref":"#/definitions/Vertex" + } + }, + "steps":{ + "type":"array", + "items":{ + "$ref":"#/definitions/Step" + } + } + } + }, + "EdgesResponse":{ + "type":"object", + "properties":{ + "size":{ + "type":"integer" + }, + "degrees":{ + "type":"array", + "items":{ + } + }, + "results":{ + "type":"array", + "items":{ + "$ref":"#/definitions/Edge" + } + }, + "impressionId":{ + "type":"integer" + } + } + }, + "Vertex":{ + "type":"object", + "properties":{ + "id":{ + "type":"string" + }, + "serviceName":{ + "type":"string" + }, + "columnName":{ + "type":"string" + }, + "timestamp":{ + "type":"integer", + }, + "props":{ + "type":"object" + } + } + }, + "Step":{ + "type":"object", + "properties":{ + "label":{ + "type":"string" + }, + "direction":{ + "type":"string" + }, + "offset":{ + "type":"integer" + }, + "limit":{ + "type":"integer" + }, + "duplicate":{ + "type":"string" + } + } + }, + "Edge":{ + "type":"object", + "properties":{ + "from":{ + "type":"string" + }, + "to":{ + "type":"string" + }, + "direction":{ + "type":"string" + }, + "label":{ + "type":"string" + }, + "score":{ + "type":"string" + }, + "cacheRemain":{ + "type":"string" + }, + "_timestamp":{ + "type":"string" + }, + "timestamp":{ + "type":"string" + }, + "props":{ + "$ref":"#/definitions/EdgeProperties" + } + } + }, + "EdgeProperties":{ + "type":"object", + "properties":{ + "_timestamp":{ + "type":"integer" + }, + "time":{ + "type":"integer" + }, + "weight":{ + "type":"integer" + }, + "is_hidden":{ + "type":"boolean" + }, + "is_blocked":{ + "type":"boolean" + } + } + } + }, + "externalDocs":{ + "description":"Find out more about Apache S2Graph", + "url":"http://s2graph.incubator.apache.org/" + } +} diff --git a/s2http/src/main/resources/META-INF/resources/s2http/swagger/v2/swagger.json b/s2http/src/main/resources/META-INF/resources/s2http/swagger/v2/swagger.json deleted file mode 100644 index f872f94d..00000000 --- a/s2http/src/main/resources/META-INF/resources/s2http/swagger/v2/swagger.json +++ /dev/null @@ -1,654 +0,0 @@ -{ - "swagger":"2.0", - "info":{ - "description":"This is S2Graph HTTP Server.", - "version":"0.2", - "title":"S2Graph HTTP Server", - "contact":{ - "email":"dev@s2graph.incubator.apache.org" - }, - "license":{ - "name":"Apache 2.0", - "url":"http://www.apache.org/licenses/LICENSE-2.0.html" - } - }, - "tags":[ - { - "name":"s2graph", - "description":"S2Graph HTTP Server", - "externalDocs":{ - "description":"Find out more about Apache S2Graph", - "url":"http://s2graph.incubator.apache.org/" - } - } - ], - "schemes":[ - "http", - "https" - ], - "paths":{ - "/admin/createService":{ - "post":{ - "tags":[ - "admin" - ], - "summary":"Create a service", - "description":"", - "operationId":"createService", - "consumes":[ - "application/json", - ], - "produces":[ - "application/json" - ], - "parameters":[ - { - "in":"body", - "name":"body", - "description":"Service", - "required":true, - "schema":{ - "$ref":"#/definitions/Service" - } - } - ], - "responses":{ - "201": { - "description":"Successfully created", - "schema":{ - "$ref":"#/definitions/ServiceResponse" - } - }, - "400":{ - "description": "Bad request" - } - } - } - }, - "/admin/createLabel":{ - "post":{ - "tags":[ - "admin" - ], - "summary":"Create a label", - "description":"", - "operationId":"createLabel", - "consumes":[ - "application/json", - ], - "produces":[ - "application/json" - ], - "parameters":[ - { - "in":"body", - "name":"body", - "description":"Service", - "required":true, - "schema":{ - "$ref":"#/definitions/Label" - } - } - ], - "responses":{ - "201":{ - "description":"Successful operation", - "schema":{ - "$ref":"#/definitions/LabelResponse" - } - }, - "400":{ - "description": "Bad request" - } - } - } - }, - "/admin/addIndex":{ - "post":{ - "tags":[ - "admin" - ], - "summary":"Add indices to a label", - "description":"", - "operationId":"addIndex", - "consumes":[ - "application/json", - ], - "produces":[ - "application/json" - ], - "parameters":[ - { - "in":"body", - "name":"body", - "description":"Label indices to add", - "required":true, - "schema":{ - "$ref":"#/definitions/LabelIndices" - } - } - ], - "responses":{ - "201":{ - "description":"Successful operation", - "schema":{ - "$ref":"#/definitions/LabelResponse" - } - }, - "400":{ - "description": "Bad request" - } - } - } - }, - "/admin/getLabel/{name}":{ - "get":{ - "tags":[ - "admin" - ], - "summary":"Get general information on a label", - "description":"", - "operationId":"getLabelByName", - "consumes":[ - "application/json", - ], - "produces":[ - "application/json" - ], - "parameters":[ - { - "in":"path", - "name":"name", - "description":"Label name", - "required":true, - "type":"string" - } - ], - "responses":{ - "200":{ - "description":"Successful operation", - "schema":{ - "$ref":"#/definitions/LabelResponse" - } - }, - "400":{ - "description": "Bad request" - } - } - } - }, - "/admin/deleteLabel/{name}":{ - "put":{ - "tags":[ - "admin" - ], - "summary":"Delete a label", - "description":"", - "operationId":"deleteLabelByName", - "consumes":[ - "application/json", - ], - "produces":[ - "application/json" - ], - "parameters":[ - { - "in":"path", - "name":"name", - "description":"Label name", - "required":true, - "type":"string" - } - ], - "responses":{ - "200":{ - "description":"Successful operation", - "schema":{ - "$ref":"#/definitions/LabelResponse" - } - }, - "400":{ - "description": "Bad request" - } - } - } - }, - "/admin/addProp/{name}":{ - "put":{ - "tags":[ - "admin" - ], - "summary":"Add a new property to the label", - "description":"", - "operationId":"addPropToLabel", - "consumes":[ - "application/json", - ], - "produces":[ - "application/json" - ], - "parameters":[ - { - "in":"path", - "name":"name", - "description":"Label name", - "required":true, - "type":"string" - }, - { - "in":"body", - "name":"body", - "description":"Property definition", - "required":true, - "schema":{ - "$ref":"#/definitions/PropertyDefinition" - } - } - ], - "responses":{ - "201":{ - "description":"Successful operation", - "schema":{ - "$ref":"#/definitions/LabelResponse" - } - }, - "400":{ - "description": "Bad request" - } - } - } - }, - "/admin/createServiceColumn":{ - "put":{ - "tags":[ - "admin" - ], - "summary":"Add a new property to the label", - "description":"", - "operationId":"addPropToLabel", - "consumes":[ - "application/json", - ], - "produces":[ - "application/json" - ], - "parameters":[ - { - "in":"body", - "name":"body", - "description":"Service column definition", - "required":true, - "schema":{ - "$ref":"#/definitions/ServiceColumn" - } - } - ], - "responses":{ - "201":{ - "description":"Successful operation", - "schema":{ - "$ref":"#/definitions/LabelResponse" - } - }, - "400":{ - "description": "Bad request" - } - } - } - } - }, - "definitions":{ - "Service":{ - "type":"object", - "required": [ - "serviceName" - ], - "properties":{ - "serviceName":{ - "description": "User defined namespace", - "type":"string" - }, - "cluster":{ - "description": "Zookeeper quorum address", - "type":"string" - }, - "hTableName":{ - "description": "HBase table name", - "type":"string" - }, - "hTableTTL":{ - "description": "Time to live setting for data", - "type":"integer" - }, - "preSplitSize":{ - "description": "Factor for the table pre-split size", - "type":"integer" - } - } - }, - "Label":{ - "type":"object", - "required": [ - "label", - "srcServiceName", - "srcColumnName", - "srcColumnType", - "tgtColumnName", - "tgtColumnType" - ], - "properties":{ - "label":{ - "description": "Name of the relation", - "type":"string" - }, - "srcServiceName":{ - "description": "Source column’s service", - "type":"string" - }, - "srcColumnName":{ - "description": "Source column’s name", - "type":"string" - }, - "srcColumnType":{ - "description": "Source column’s data type", - "type":"string", - "enum": [ - "long", - "integer", - "string" - ] - }, - "tgtServiceName":{ - "description": "Target column’s service", - "type":"string" - }, - "tgtColumnName":{ - "description": "Target column’s name", - "type":"string" - }, - "tgtColumnType":{ - "description": "Target column’s data type", - "type":"string", - "enum": [ - "long", - "integer", - "string" - ] - }, - "indices": { - "description": "Index definitions on the label", - "type": "array", - "items": { - "$ref":"#/definitions/IndexDefinition" - } - }, - "props": { - "description": "Property definitions on the label", - "type": "array", - "items": { - "$ref":"#/definitions/PropertyDefinition" - } - }, - "isDirected":{ - "description": "Wether the label is directed or undirected", - "type":"integer" - }, - "serviceName":{ - "description": "Which service the label belongs to", - "type":"string" - }, - "hTableName":{ - "description": "A dedicated HBase table to your Label", - "type":"string" - }, - "hTableTTL":{ - "description": "Data time to live setting", - "type":"integer" - }, - "consistencyLevel":{ - "description": "If set to ‘strong’, only one edge is alowed between a pair of source/ target vertices. Set to ‘weak’, and multiple-edge is supported", - "type":"string", - "enum": [ - "weak", - "strong" - ] - } - } - }, - "LabelIndices":{ - "type":"object", - "required": [ - "label", - ], - "properties":{ - "label":{ - "description": "Name of the relation", - "type":"string" - }, - "indices": { - "description": "Index definitions on the label", - "type": "array", - "items": { - "$ref":"#/definitions/IndexDefinition" - } - } - } - }, - "IndexDefinition":{ - "type":"object", - "required": [ - "name", - "propNames" - ], - "properties":{ - "name":{ - "description": "Label index name", - "type":"string" - }, - "propNames":{ - "description": "Label property names used by the index", - "type":"array", - "items": { - "type": "string" - } - }, - "dir":{ - "type":"string" - }, - "options":{ - "type":"string" - } - } - }, - "PropertyDefinition":{ - "type":"object", - "required": [ - "name", - "dataType" - ], - "properties":{ - "name":{ - "description": "Label property name", - "type":"string" - }, - "dataType":{ - "description": "Data type of the label property", - "type":"string" - }, - "defaultValue":{ - "description": "Default value of the label property", - "type":"string" - } - } - }, - "ServiceResponse": { - "type":"object", - "required": [ - "status" - ], - "properties":{ - "status":{ - "description": "Status", - "type":"string" - }, - "messasge":{ - "$ref":"#/definitions/ServiceResponseMessage" - } - } - }, - "ServiceResponseMessage": { - "type":"object", - "required": [ - "id", - "name" - ], - "properties":{ - "id":{ - "description": "Message ID", - "type":"string" - }, - "name":{ - "description": "User defined namespace", - "type":"string" - }, - "accessToken":{ - "description": "Access token", - "type":"string" - }, - "cluster":{ - "description": "Zookeeper quorum address", - "type":"string" - }, - "hTableName":{ - "description": "HBase table name", - "type":"string" - }, - "hTableTTL":{ - "description": "Time to live setting for data", - "type":"integer" - }, - "preSplitSize":{ - "description": "Factor for the table pre-split size", - "type":"integer" - } - } - }, - "LabelResponse": { - "type":"object", - "required": [ - "status" - ], - "properties":{ - "status":{ - "description": "Status", - "type":"string" - }, - "messasge":{ - "$ref":"#/definitions/LabelResponseMessage" - } - } - }, - "LabelResponseMessage": { - "type":"object", - "required": [ - "labelName" - ], - "properties":{ - "labelName":{ - "description": "The label name", - "type":"string" - }, - "from":{ - "$ref":"#/definitions/ServiceLabelColumn" - }, - "to":{ - "$ref":"#/definitions/ServiceLabelColumn" - }, - "isDirected":{ - "type":"boolean" - }, - "serviceName":{ - "description": "User defined namespace", - "type":"string" - }, - "consistencyLevel":{ - "description": "If set to ‘strong’, only one edge is alowed between a pair of source/ target vertices. Set to ‘weak’, and multiple-edge is supported", - "type":"string", - "enum": [ - "weak", - "strong" - ] - }, - "schemaVersion":{ - "type":"string" - }, - "isAsync":{ - "type":"boolean" - }, - "compressionAlgorithm":{ - "type":"string" - }, - "defaultIndex":{ - "$ref":"#/definitions/IndexDefinition" - }, - "extraIndex":{ - "type":"array", - "items":{ - "$ref":"#/definitions/IndexDefinition" - } - }, - "metaProps":{ - "type":"array", - "items":{ - "$ref":"#/definitions/PropertyDefinition" - } - }, - "options":{ - "type":"string" - } - } - }, - "ServiceColumn": { - "type": "object", - "properties": { - "serviceName": { - "type":"string" - }, - "columnName": { - "type":"string" - }, - "columnType": { - "type":"string" - }, - "props": { - "description": "Property definitions", - "type": "array", - "items": { - "$ref":"#/definitions/PropertyDefinition" - } - } - } - }, - "ServiceLabelColumn": { - "type": "object", - "properties": { - "from": { - "type":"string" - }, - "serviceName": { - "type":"string" - }, - "columnName": { - "type":"string" - }, - "columnType": { - "type":"string" - } - } - } - }, - "externalDocs":{ - "description":"Find out more about Apache S2Graph", - "url":"http://s2graph.incubator.apache.org/" - } -} From 9319d3188208d9797c53929cae906f86407307a2 Mon Sep 17 00:00:00 2001 From: Woonsan Ko Date: Sun, 28 Apr 2019 00:23:46 -0400 Subject: [PATCH 5/5] S2GRAPH-253: polishing with patterns; fixing json output of health endpoint and swagger json error --- .../resources/s2http/swagger/v0/swagger.json | 2 +- .../scala/org/apache/s2graph/http/Server.scala | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/s2http/src/main/resources/META-INF/resources/s2http/swagger/v0/swagger.json b/s2http/src/main/resources/META-INF/resources/s2http/swagger/v0/swagger.json index 62aadea0..a8d8bdaf 100644 --- a/s2http/src/main/resources/META-INF/resources/s2http/swagger/v0/swagger.json +++ b/s2http/src/main/resources/META-INF/resources/s2http/swagger/v0/swagger.json @@ -1186,7 +1186,7 @@ "type":"string" }, "timestamp":{ - "type":"integer", + "type":"integer" }, "props":{ "type":"object" 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 2ce8dd34..fb276f89 100644 --- a/s2http/src/main/scala/org/apache/s2graph/http/Server.scala +++ b/s2http/src/main/scala/org/apache/s2graph/http/Server.scala @@ -61,7 +61,7 @@ object Server extends App def uptime = System.currentTimeMillis() - startAt - def serverHealth = s"""{ "port": ${port}, "interface": "${interface}", "started_at": ${Instant.ofEpochMilli(startAt)}, "uptime": "${uptime} millis" """ + def serverHealth = s"""{ "port": ${port}, "interface": "${interface}", "started_at": "${Instant.ofEpochMilli(startAt)}", "uptime": "${uptime} millis" }""" def health = HttpResponse(status = StatusCodes.OK, entity = HttpEntity(ContentTypes.`application/json`, serverHealth)) @@ -76,13 +76,12 @@ object Server extends App redirect("/api-docs/", StatusCodes.TemporaryRedirect) } ~ path(Segments) { segs => { - val resPath = segs.mkString("/") - if (resPath.isEmpty || resPath == SwaggerIndexPage) - getFromResource(SwaggerIndexResPath) - else if (resPath.startsWith("s2http")) - getFromResource("META-INF/resources/" + resPath) - else - getFromResource(SwaggerWebJarBaseResPath + resPath) + val resPath = segs match { + case Nil | SwaggerIndexPage :: Nil => SwaggerIndexResPath + case "s2http" :: rest => "META-INF/resources/s2http/" + rest.mkString("/") + case _ => SwaggerWebJarBaseResPath + segs.mkString("/") + } + getFromResource(resPath) } } },