You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nlpcraft.apache.org by ar...@apache.org on 2020/10/14 03:25:11 UTC
[incubator-nlpcraft] 02/23: WIP.
This is an automated email from the ASF dual-hosted git repository.
aradzinski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
commit 56842f8dda4ad2048ed7f44e72014842f9f6382c
Author: Aaron Radzinski <ar...@datalingvo.com>
AuthorDate: Fri Oct 9 18:12:09 2020 -0700
WIP.
---
.../nlpcraft/model/tools/cmdline/NCCli.scala | 61 ++++++++++++----------
openapi/nlpcraft_swagger.yml | 53 ++++++++++++-------
2 files changed, 68 insertions(+), 46 deletions(-)
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala
index bfa5c0c..7e514c2 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala
@@ -68,35 +68,40 @@ object NCCli extends App {
//noinspection RegExpRedundantEscape
private final val TAILER_PTRN = Pattern.compile("^.*NC[a-zA-Z0-9]+ started \\[[\\d]+ms\\]$")
+ case class RestCall(
+ path: String,
+ desc: String,
+ group: String
+ )
+
// TODO: this needs to be loaded dynamically from OpenAPI spec.
private final val REST_PATHS = Seq(
- "clear/conversation" -> "Clears conversation STM",
- "clear/dialog" -> "Clears dialog flow",
- "model/sugsyn" -> "Runs model synonym suggestion tool",
- "check" -> "Gets status and result of submitted requests",
- "cancel" -> "Cancels a question",
- "ask" -> "Asks a question",
- "ask/sync" -> "Asks a question in synchronous mode",
- "user/get" -> "Gets current user information",
- "user/all" -> "Gets all users",
- "user/update" -> "Updates regular user",
- "user/delete" -> "Deletes user",
- "user/admin" -> "Updates user admin permissions",
- "user/passwd/reset" -> "Resets password for the user",
- "user/add" -> "Adds new user",
- "company/get" -> "Gets current user company information",
- "company/add" -> "Adds new company",
- "company/update" -> "Updates company data",
- "company/delete" -> "Deletes company",
- "company/token/reset" -> "Resets company probe auth token",
- "feedback/add" -> "Adds feedback",
- "feedback/delete" -> "Deletes feedback",
- "feedback/all" -> "Gets all feedback",
- "signin" -> "Signs in and obtains new access token",
- "signout" -> "Signs out and releases access token",
- "probe/all" -> "Gets all probes"
+ RestCall("clear/conversation", "Clears conversation STM", "Asking"),
+ RestCall("clear/dialog", "Clears dialog flow", "Asking"),
+ RestCall("model/sugsyn", "Runs model synonym suggestion tool", "Tools"),
+ RestCall("check", "Gets status and result of submitted requests", "Asking"),
+ RestCall("cancel", "Cancels a question", "Asking"),
+ RestCall("ask", "Asks a question", "Asking"),
+ RestCall("ask/sync", "Asks a question in synchronous mode", "Asking"),
+ RestCall("user/get", "Gets current user information", "User"),
+ RestCall("user/all", "Gets all users", "User"),
+ RestCall("user/update", "Updates regular user", "User"),
+ RestCall("user/delete", "Deletes user", "User"),
+ RestCall("user/admin", "Updates user admin permissions", "User"),
+ RestCall("user/passwd/reset", "Resets password for the user", "User"),
+ RestCall("user/add", "Adds new user", "User"),
+ RestCall("company/get", "Gets current user company information", "Company"),
+ RestCall("company/add", "Adds new company", "Company"),
+ RestCall("company/update", "Updates company data", "Company"),
+ RestCall("company/delete", "Deletes company", "Company"),
+ RestCall("company/token/reset", "Resets company probe auth token", "Company"),
+ RestCall("feedback/add", "Adds feedback", "Asking"),
+ RestCall("feedback/delete", "Deletes feedback", "Asking"),
+ RestCall("feedback/all", "Gets all feedback", "Asking"),
+ RestCall("signin", "Signs in and obtains new access token", "Authentication"),
+ RestCall("signout", "Signs out and releases access token", "Authentication"),
+ RestCall("probe/all", "Gets all probes", "Probe")
)
- .sortBy(_._1)
// Number of server services that need to be started + 1 progress start.
// Used for progress bar functionality.
@@ -1160,13 +1165,13 @@ object NCCli extends App {
if (!repl)
header()
- CMDS.groupBy(_.group).foreach(entry ⇒ {
+ CMDS.groupBy(_.group).toSeq.sortBy(_._1).foreach(entry ⇒ {
val grp = entry._1
val grpCmds = entry._2
val tbl = NCAsciiTable().margin(left = if (repl) 0 else 4)
- grpCmds.foreach(cmd ⇒ tbl +/ (
+ grpCmds.sortBy(_.name).foreach(cmd ⇒ tbl +/ (
"" → s"${g(cmd.name)}",
"align:left, maxWidth:85" → cmd.synopsis
))
diff --git a/openapi/nlpcraft_swagger.yml b/openapi/nlpcraft_swagger.yml
index 32d0f8d..0a3b885 100644
--- a/openapi/nlpcraft_swagger.yml
+++ b/openapi/nlpcraft_swagger.yml
@@ -158,10 +158,27 @@ paths:
description: Failed operation.
schema:
$ref: '#/definitions/Error'
+ /health:
+ get:
+ tags:
+ - Tools
+ summary: Health ping.
+ description: >-
+ Pings server for HTTP 200 code.
+ operationId: health
+ responses:
+ '200':
+ description: Successful operation.
+ schema:
+ $ref: '#/definitions/Ok'
+ '400':
+ description: Failed operation.
+ schema:
+ $ref: '#/definitions/Error'
/model/sugsyn:
post:
tags:
- - Model
+ - Tools
summary: Runs model synonym suggestion tool.
description: >-
Runs model synonym suggestion tool that is based on BERT models and uses @NCIntentSample annotation.
@@ -648,7 +665,7 @@ paths:
/user/get:
post:
tags:
- - Users
+ - User
summary: Gets current user information.
description: Gets current user information.
operationId: getUser
@@ -731,7 +748,7 @@ paths:
/user/all:
post:
tags:
- - Users
+ - User
summary: Gets all users.
description: Gets all users for the current user company. Administrative privileges required.
operationId: getAllUsers
@@ -756,7 +773,7 @@ paths:
type: object
required:
- status
- - users
+ - User
properties:
status:
type: string
@@ -805,7 +822,7 @@ paths:
/user/update:
post:
tags:
- - Users
+ - User
summary: Updates regular user.
description: >-
Updates user with given ID or the current user with given parameters.
@@ -862,7 +879,7 @@ paths:
/user/delete:
post:
tags:
- - Users
+ - User
summary: Deletes user.
description: >-
Deletes user with given ID or the current user.
@@ -909,7 +926,7 @@ paths:
/user/admin:
post:
tags:
- - Users
+ - User
summary: Updates user admin permissions.
description: >-
Updates user's permissions with given ID or the current user.
@@ -950,7 +967,7 @@ paths:
/user/passwd/reset:
post:
tags:
- - Users
+ - User
summary: Resets password for the user.
description: >-
Resets the password for the user. Note that NLPCraft doesn't store password in reversible way
@@ -993,7 +1010,7 @@ paths:
/user/add:
post:
tags:
- - Users
+ - User
summary: Adds new user.
description: Adds new user with given parameters to the company of the admin caller. Administrative privileges required.
operationId: addUser
@@ -1072,7 +1089,7 @@ paths:
/company/get:
post:
tags:
- - Companies
+ - Company
summary: Gets current user company information.
description: Gets current user company information.
operationId: getCompany
@@ -1137,7 +1154,7 @@ paths:
/company/add:
post:
tags:
- - Companies
+ - Company
summary: Adds new company.
description: >-
Adds new company with given parameters.
@@ -1238,7 +1255,7 @@ paths:
/company/update:
post:
tags:
- - Companies
+ - Company
summary: Updates company data.
description: >-
Updates company data with given parameters.
@@ -1299,7 +1316,7 @@ paths:
/company/delete:
post:
tags:
- - Companies
+ - Company
summary: Deletes company.
description: >-
Deletes company.
@@ -1331,7 +1348,7 @@ paths:
/company/token/reset:
post:
tags:
- - Companies
+ - Company
summary: Resets company probe authentication token.
description: >-
Sets and returns new company probe authentication token.
@@ -1375,7 +1392,7 @@ paths:
/feedback/add:
post:
tags:
- - Feedbacks
+ - Asking
summary: Adds feedback.
description: Adds feedback for processed user request.
operationId: addFeedback
@@ -1440,7 +1457,7 @@ paths:
/feedback/delete:
post:
tags:
- - Feedbacks
+ - Asking
summary: Deletes feedback.
description: >-
Deletes feedback for given record ID.
@@ -1477,7 +1494,7 @@ paths:
/feedback/all:
post:
tags:
- - Feedbacks
+ - Asking
summary: Gets feedback.
description: >-
Gets all request feedback records.
@@ -1657,7 +1674,7 @@ paths:
/probe/all:
post:
tags:
- - Data Probes
+ - Probe
summary: Gets all probes.
description: >-
Gets metadata for all active (currently connected) probes. Administrative privileges required.