jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/348428 )
Change subject: Add /list/tool/{tool} API end point
......................................................................
Add /list/tool/{tool} API end point
Bug: T162576
Change-Id: I08c004d484601bfe6aeb7ea4d64b93dc7e014985
---
M routes/v1.js
M spec.yaml
2 files changed, 50 insertions(+), 1 deletion(-)
Approvals:
Mobrovac: Looks good to me, approved
jenkins-bot: Verified
diff --git a/routes/v1.js b/routes/v1.js
index 2113d63..62b642f 100644
--- a/routes/v1.js
+++ b/routes/v1.js
@@ -164,6 +164,29 @@
} );
/**
+ * Get a list of all language pairs that tool supports.
+ */
+router.get( '/list/tool/:tool', function ( req, res ) {
+ var result,
+ tool = req.params.tool;
+
+ registry = require( __dirname + '/../registry' )( app );
+ if ( tool === 'mt' ) {
+ result = registry.getMTPairs();
+ }
+ if ( tool === 'dictionary' ) {
+ result = registry.getDictionaryPairs();
+ }
+
+ if ( !result ) {
+ res.status( 404 ).end( 'Unknown tool' );
+ return;
+ }
+
+ res.json( result );
+} );
+
+/**
* Get a list of all language pairs.
*/
router.get( '/languagepairs', function ( req, res ) {
diff --git a/spec.yaml b/spec.yaml
index d6ab70b..95687e0 100644
--- a/spec.yaml
+++ b/spec.yaml
@@ -200,12 +200,38 @@
contents: /.+/
headers:
content-type: application/json
+ /v1/list/tool/{tool}:
+ get:
+ tags:
+ - Tools
+ - Service information
+ description: Lists the tools for all language pairs
+ produces:
+ - application/json
+ parameters:
+ - name: tool
+ in: path
+ description: The tool name
+ type: string
+ required: true
+ enum:
+ - mt
+ - dictionary
+ x-amples:
+ - title: Get the tools for all language pairs
+ request:
+ params:
+ tool: mt
+ response:
+ status: 200
+ headers:
+ content-type: application/json
/v1/list/{tool}{/from}{/to}:
get:
tags:
- Tools
- Service information
- description: Lists the tools for a language pair
+ description: Lists all language pairs that tool supports
produces:
- application/json
parameters:
--
To view, visit https://gerrit.wikimedia.org/r/348428
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I08c004d484601bfe6aeb7ea4d64b93dc7e014985
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/services/cxserver
Gerrit-Branch: master
Gerrit-Owner: KartikMistry <[email protected]>
Gerrit-Reviewer: KartikMistry <[email protected]>
Gerrit-Reviewer: Mobrovac <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: Santhosh <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits