Skip to content
Permalink
Browse files

add initial support to rest-specs

  • Loading branch information...
tsouza committed Nov 12, 2017
1 parent 1cb3d45 commit ad87291670588b352fc2fc53e2f9d7944c77a516
Showing with 12,001 additions and 9 deletions.
  1. +2 −0 .gitignore
  2. +42 −0 build/restSpecIndex.js
  3. +14 −9 package.json
  4. +109 −0 src/ElasticCompletionItemProvider.ts
  5. +3 −0 src/extension.ts
  6. +7 −0 src/rest-spec/index.ts
  7. +1 −0 src/rest-spec/json.d.ts
  8. +52 −0 src/rest-spec/v2_4_6/bulk.json
  9. +41 −0 src/rest-spec/v2_4_6/cat.aliases.json
  10. +46 −0 src/rest-spec/v2_4_6/cat.allocation.json
  11. +41 −0 src/rest-spec/v2_4_6/cat.count.json
  12. +50 −0 src/rest-spec/v2_4_6/cat.fielddata.json
  13. +42 −0 src/rest-spec/v2_4_6/cat.health.json
  14. +20 −0 src/rest-spec/v2_4_6/cat.help.json
  15. +51 −0 src/rest-spec/v2_4_6/cat.indices.json
  16. +37 −0 src/rest-spec/v2_4_6/cat.master.json
  17. +37 −0 src/rest-spec/v2_4_6/cat.nodeattrs.json
  18. +37 −0 src/rest-spec/v2_4_6/cat.nodes.json
  19. +37 −0 src/rest-spec/v2_4_6/cat.pending_tasks.json
  20. +35 −0 src/rest-spec/v2_4_6/cat.plugins.json
  21. +42 −0 src/rest-spec/v2_4_6/cat.recovery.json
  22. +38 −0 src/rest-spec/v2_4_6/cat.repositories.json
  23. +33 −0 src/rest-spec/v2_4_6/cat.segments.json
  24. +41 −0 src/rest-spec/v2_4_6/cat.shards.json
  25. +43 −0 src/rest-spec/v2_4_6/cat.snapshots.json
  26. +42 −0 src/rest-spec/v2_4_6/cat.thread_pool.json
  27. +20 −0 src/rest-spec/v2_4_6/clear_scroll.json
  28. +26 −0 src/rest-spec/v2_4_6/cluster.get_settings.json
  29. +55 −0 src/rest-spec/v2_4_6/cluster.health.json
  30. +23 −0 src/rest-spec/v2_4_6/cluster.pending_tasks.json
  31. +28 −0 src/rest-spec/v2_4_6/cluster.put_settings.json
  32. +38 −0 src/rest-spec/v2_4_6/cluster.reroute.json
  33. +54 −0 src/rest-spec/v2_4_6/cluster.state.json
  34. +32 −0 src/rest-spec/v2_4_6/cluster.stats.json
  35. +81 −0 src/rest-spec/v2_4_6/count.json
  36. +72 −0 src/rest-spec/v2_4_6/count_percolate.json
  37. +60 −0 src/rest-spec/v2_4_6/delete.json
  38. +34 −0 src/rest-spec/v2_4_6/delete_script.json
  39. +29 −0 src/rest-spec/v2_4_6/delete_template.json
  40. +50 −0 src/rest-spec/v2_4_6/exists.json
  41. +90 −0 src/rest-spec/v2_4_6/explain.json
  42. +49 −0 src/rest-spec/v2_4_6/field_stats.json
  43. +75 −0 src/rest-spec/v2_4_6/get.json
  44. +34 −0 src/rest-spec/v2_4_6/get_script.json
  45. +71 −0 src/rest-spec/v2_4_6/get_source.json
  46. +29 −0 src/rest-spec/v2_4_6/get_template.json
  47. +76 −0 src/rest-spec/v2_4_6/index.json
  48. +231 −0 src/rest-spec/v2_4_6/index.ts
  49. +75 −0 src/rest-spec/v2_4_6/indices.analyze.json
  50. +61 −0 src/rest-spec/v2_4_6/indices.clear_cache.json
  51. +42 −0 src/rest-spec/v2_4_6/indices.close.json
  52. +34 −0 src/rest-spec/v2_4_6/indices.create.json
  53. +28 −0 src/rest-spec/v2_4_6/indices.delete.json
  54. +33 −0 src/rest-spec/v2_4_6/indices.delete_alias.json
  55. +28 −0 src/rest-spec/v2_4_6/indices.delete_template.json
  56. +33 −0 src/rest-spec/v2_4_6/indices.delete_warmer.json
  57. +38 −0 src/rest-spec/v2_4_6/indices.exists.json
  58. +41 −0 src/rest-spec/v2_4_6/indices.exists_alias.json
  59. +28 −0 src/rest-spec/v2_4_6/indices.exists_template.json
  60. +43 −0 src/rest-spec/v2_4_6/indices.exists_type.json
  61. +41 −0 src/rest-spec/v2_4_6/indices.flush.json
  62. +41 −0 src/rest-spec/v2_4_6/indices.flush_synced.json
  63. +52 −0 src/rest-spec/v2_4_6/indices.forcemerge.json
  64. +52 −0 src/rest-spec/v2_4_6/indices.get.json
  65. +41 −0 src/rest-spec/v2_4_6/indices.get_alias.json
  66. +31 −0 src/rest-spec/v2_4_6/indices.get_aliases.json
  67. +50 −0 src/rest-spec/v2_4_6/indices.get_field_mapping.json
  68. +41 −0 src/rest-spec/v2_4_6/indices.get_mapping.json
  69. +50 −0 src/rest-spec/v2_4_6/indices.get_settings.json
  70. +35 −0 src/rest-spec/v2_4_6/indices.get_template.json
  71. +38 −0 src/rest-spec/v2_4_6/indices.get_upgrade.json
  72. +45 −0 src/rest-spec/v2_4_6/indices.get_warmer.json
  73. +42 −0 src/rest-spec/v2_4_6/indices.open.json
  74. +52 −0 src/rest-spec/v2_4_6/indices.optimize.json
  75. +36 −0 src/rest-spec/v2_4_6/indices.put_alias.json
  76. +53 −0 src/rest-spec/v2_4_6/indices.put_mapping.json
  77. +44 −0 src/rest-spec/v2_4_6/indices.put_settings.json
  78. +44 −0 src/rest-spec/v2_4_6/indices.put_template.json
  79. +53 −0 src/rest-spec/v2_4_6/indices.put_warmer.json
  80. +34 −0 src/rest-spec/v2_4_6/indices.recovery.json
  81. +41 −0 src/rest-spec/v2_4_6/indices.refresh.json
  82. +46 −0 src/rest-spec/v2_4_6/indices.segments.json
  83. +41 −0 src/rest-spec/v2_4_6/indices.shard_stores.json
  84. +60 −0 src/rest-spec/v2_4_6/indices.stats.json
  85. +26 −0 src/rest-spec/v2_4_6/indices.update_aliases.json
  86. +41 −0 src/rest-spec/v2_4_6/indices.upgrade.json
  87. +80 −0 src/rest-spec/v2_4_6/indices.validate_query.json
  88. +15 −0 src/rest-spec/v2_4_6/info.json
  89. +58 −0 src/rest-spec/v2_4_6/mget.json
  90. +41 −0 src/rest-spec/v2_4_6/mpercolate.json
  91. +32 −0 src/rest-spec/v2_4_6/msearch.json
  92. +96 −0 src/rest-spec/v2_4_6/mtermvectors.json
  93. +44 −0 src/rest-spec/v2_4_6/nodes.hot_threads.json
  94. +37 −0 src/rest-spec/v2_4_6/nodes.info.json
  95. +71 −0 src/rest-spec/v2_4_6/nodes.stats.json
  96. +85 −0 src/rest-spec/v2_4_6/percolate.json
  97. +15 −0 src/rest-spec/v2_4_6/ping.json
  98. +43 −0 src/rest-spec/v2_4_6/put_script.json
  99. +38 −0 src/rest-spec/v2_4_6/put_template.json
  100. +41 −0 src/rest-spec/v2_4_6/reindex.json
  101. +24 −0 src/rest-spec/v2_4_6/reindex_rethrottle.json
  102. +19 −0 src/rest-spec/v2_4_6/render_search_template.json
  103. +29 −0 src/rest-spec/v2_4_6/scroll.json
  104. +164 −0 src/rest-spec/v2_4_6/search.json
  105. +81 −0 src/rest-spec/v2_4_6/search_exists.json
  106. +49 −0 src/rest-spec/v2_4_6/search_shards.json
  107. +56 −0 src/rest-spec/v2_4_6/search_template.json
  108. +37 −0 src/rest-spec/v2_4_6/snapshot.create.json
  109. +35 −0 src/rest-spec/v2_4_6/snapshot.create_repository.json
  110. +29 −0 src/rest-spec/v2_4_6/snapshot.delete.json
  111. +28 −0 src/rest-spec/v2_4_6/snapshot.delete_repository.json
  112. +29 −0 src/rest-spec/v2_4_6/snapshot.get.json
  113. +27 −0 src/rest-spec/v2_4_6/snapshot.get_repository.json
  114. +37 −0 src/rest-spec/v2_4_6/snapshot.restore.json
  115. +27 −0 src/rest-spec/v2_4_6/snapshot.status.json
  116. +28 −0 src/rest-spec/v2_4_6/snapshot.verify_repository.json
  117. +44 −0 src/rest-spec/v2_4_6/suggest.json
  118. +35 −0 src/rest-spec/v2_4_6/tasks.cancel.json
  119. +43 −0 src/rest-spec/v2_4_6/tasks.list.json
  120. +102 −0 src/rest-spec/v2_4_6/termvectors.json
  121. +94 −0 src/rest-spec/v2_4_6/update.json
  122. +210 −0 src/rest-spec/v2_4_6/update_by_query.json
  123. +29 −0 src/rest-spec/v5_6_4/_common.json
  124. +68 −0 src/rest-spec/v5_6_4/bulk.json
  125. +49 −0 src/rest-spec/v5_6_4/cat.aliases.json
  126. +54 −0 src/rest-spec/v5_6_4/cat.allocation.json
  127. +49 −0 src/rest-spec/v5_6_4/cat.count.json
  128. +58 −0 src/rest-spec/v5_6_4/cat.fielddata.json
  129. +50 −0 src/rest-spec/v5_6_4/cat.health.json
  130. +24 −0 src/rest-spec/v5_6_4/cat.help.json
  131. +65 −0 src/rest-spec/v5_6_4/cat.indices.json
  132. +45 −0 src/rest-spec/v5_6_4/cat.master.json
  133. +45 −0 src/rest-spec/v5_6_4/cat.nodeattrs.json
  134. +49 −0 src/rest-spec/v5_6_4/cat.nodes.json
  135. +45 −0 src/rest-spec/v5_6_4/cat.pending_tasks.json
  136. +43 −0 src/rest-spec/v5_6_4/cat.plugins.json
  137. +50 −0 src/rest-spec/v5_6_4/cat.recovery.json
  138. +46 −0 src/rest-spec/v5_6_4/cat.repositories.json
  139. +46 −0 src/rest-spec/v5_6_4/cat.segments.json
  140. +54 −0 src/rest-spec/v5_6_4/cat.shards.json
  141. +53 −0 src/rest-spec/v5_6_4/cat.snapshots.json
  142. +57 −0 src/rest-spec/v5_6_4/cat.tasks.json
  143. +49 −0 src/rest-spec/v5_6_4/cat.templates.json
  144. +54 −0 src/rest-spec/v5_6_4/cat.thread_pool.json
  145. +20 −0 src/rest-spec/v5_6_4/clear_scroll.json
  146. +24 −0 src/rest-spec/v5_6_4/cluster.allocation_explain.json
  147. +31 −0 src/rest-spec/v5_6_4/cluster.get_settings.json
  148. +60 −0 src/rest-spec/v5_6_4/cluster.health.json
  149. +23 −0 src/rest-spec/v5_6_4/cluster.pending_tasks.json
  150. +28 −0 src/rest-spec/v5_6_4/cluster.put_settings.json
  151. +42 −0 src/rest-spec/v5_6_4/cluster.reroute.json
  152. +54 −0 src/rest-spec/v5_6_4/cluster.state.json
  153. +27 −0 src/rest-spec/v5_6_4/cluster.stats.json
  154. +81 −0 src/rest-spec/v5_6_4/count.json
  155. +72 −0 src/rest-spec/v5_6_4/count_percolate.json
  156. +75 −0 src/rest-spec/v5_6_4/create.json
  157. +60 −0 src/rest-spec/v5_6_4/delete.json
  158. +169 −0 src/rest-spec/v5_6_4/delete_by_query.json
  159. +33 −0 src/rest-spec/v5_6_4/delete_script.json
  160. +20 −0 src/rest-spec/v5_6_4/delete_template.json
  161. +75 −0 src/rest-spec/v5_6_4/exists.json
  162. +71 −0 src/rest-spec/v5_6_4/exists_source.json
  163. +86 −0 src/rest-spec/v5_6_4/explain.json
  164. +43 −0 src/rest-spec/v5_6_4/field_caps.json
  165. +49 −0 src/rest-spec/v5_6_4/field_stats.json
  166. +75 −0 src/rest-spec/v5_6_4/get.json
  167. +25 −0 src/rest-spec/v5_6_4/get_script.json
  168. +71 −0 src/rest-spec/v5_6_4/get_source.json
  169. +20 −0 src/rest-spec/v5_6_4/get_template.json
  170. +80 −0 src/rest-spec/v5_6_4/index.json
  171. +255 −0 src/rest-spec/v5_6_4/index.ts
  172. +67 −0 src/rest-spec/v5_6_4/indices.analyze.json
  173. +65 −0 src/rest-spec/v5_6_4/indices.clear_cache.json
  174. +42 −0 src/rest-spec/v5_6_4/indices.close.json
  175. +38 −0 src/rest-spec/v5_6_4/indices.create.json
  176. +28 −0 src/rest-spec/v5_6_4/indices.delete.json
  177. +33 −0 src/rest-spec/v5_6_4/indices.delete_alias.json
  178. +28 −0 src/rest-spec/v5_6_4/indices.delete_template.json
  179. +47 −0 src/rest-spec/v5_6_4/indices.exists.json
  180. +41 −0 src/rest-spec/v5_6_4/indices.exists_alias.json
  181. +32 −0 src/rest-spec/v5_6_4/indices.exists_template.json
  182. +43 −0 src/rest-spec/v5_6_4/indices.exists_type.json
  183. +41 −0 src/rest-spec/v5_6_4/indices.flush.json
  184. +41 −0 src/rest-spec/v5_6_4/indices.flush_synced.json
  185. +52 −0 src/rest-spec/v5_6_4/indices.forcemerge.json
  186. +52 −0 src/rest-spec/v5_6_4/indices.get.json
  187. +41 −0 src/rest-spec/v5_6_4/indices.get_alias.json
  188. +50 −0 src/rest-spec/v5_6_4/indices.get_field_mapping.json
  189. +41 −0 src/rest-spec/v5_6_4/indices.get_mapping.json
  190. +50 −0 src/rest-spec/v5_6_4/indices.get_settings.json
  191. +35 −0 src/rest-spec/v5_6_4/indices.get_template.json
  192. +33 −0 src/rest-spec/v5_6_4/indices.get_upgrade.json
  193. +42 −0 src/rest-spec/v5_6_4/indices.open.json
  194. +36 −0 src/rest-spec/v5_6_4/indices.put_alias.json
  195. +53 −0 src/rest-spec/v5_6_4/indices.put_mapping.json
  196. +48 −0 src/rest-spec/v5_6_4/indices.put_settings.json
  197. +44 −0 src/rest-spec/v5_6_4/indices.put_template.json
  198. +29 −0 src/rest-spec/v5_6_4/indices.recovery.json
  199. +33 −0 src/rest-spec/v5_6_4/indices.refresh.json
  200. +43 −0 src/rest-spec/v5_6_4/indices.rollover.json
  201. +41 −0 src/rest-spec/v5_6_4/indices.segments.json
  202. +41 −0 src/rest-spec/v5_6_4/indices.shard_stores.json
  203. +39 −0 src/rest-spec/v5_6_4/indices.shrink.json
  204. +60 −0 src/rest-spec/v5_6_4/indices.stats.json
  205. +26 −0 src/rest-spec/v5_6_4/indices.update_aliases.json
  206. +41 −0 src/rest-spec/v5_6_4/indices.upgrade.json
  207. +80 −0 src/rest-spec/v5_6_4/indices.validate_query.json
  208. +15 −0 src/rest-spec/v5_6_4/info.json
  209. +28 −0 src/rest-spec/v5_6_4/ingest.delete_pipeline.json
  210. +23 −0 src/rest-spec/v5_6_4/ingest.get_pipeline.json
  211. +15 −0 src/rest-spec/v5_6_4/ingest.processor.grok.json
  212. +31 −0 src/rest-spec/v5_6_4/ingest.put_pipeline.json
  213. +28 −0 src/rest-spec/v5_6_4/ingest.simulate.json
  214. +58 −0 src/rest-spec/v5_6_4/mget.json
  215. +41 −0 src/rest-spec/v5_6_4/mpercolate.json
  216. +45 −0 src/rest-spec/v5_6_4/msearch.json
  217. +40 −0 src/rest-spec/v5_6_4/msearch_template.json
  218. +96 −0 src/rest-spec/v5_6_4/mtermvectors.json
  219. +44 −0 src/rest-spec/v5_6_4/nodes.hot_threads.json
  220. +32 −0 src/rest-spec/v5_6_4/nodes.info.json
  221. +71 −0 src/rest-spec/v5_6_4/nodes.stats.json
  222. +85 −0 src/rest-spec/v5_6_4/percolate.json
  223. +15 −0 src/rest-spec/v5_6_4/ping.json
  224. +36 −0 src/rest-spec/v5_6_4/put_script.json
  225. +23 −0 src/rest-spec/v5_6_4/put_template.json
  226. +45 −0 src/rest-spec/v5_6_4/reindex.json
  227. +24 −0 src/rest-spec/v5_6_4/reindex_rethrottle.json
  228. +12 −0 src/rest-spec/v5_6_4/remote.info.json
  229. +19 −0 src/rest-spec/v5_6_4/render_search_template.json
  230. +29 −0 src/rest-spec/v5_6_4/scroll.json
  231. +183 −0 src/rest-spec/v5_6_4/search.json
  232. +49 −0 src/rest-spec/v5_6_4/search_shards.json
  233. +68 −0 src/rest-spec/v5_6_4/search_template.json
  234. +37 −0 src/rest-spec/v5_6_4/snapshot.create.json
  235. +35 −0 src/rest-spec/v5_6_4/snapshot.create_repository.json
  236. +29 −0 src/rest-spec/v5_6_4/snapshot.delete.json
  237. +28 −0 src/rest-spec/v5_6_4/snapshot.delete_repository.json
  238. +37 −0 src/rest-spec/v5_6_4/snapshot.get.json
  239. +27 −0 src/rest-spec/v5_6_4/snapshot.get_repository.json
  240. +37 −0 src/rest-spec/v5_6_4/snapshot.restore.json
  241. +31 −0 src/rest-spec/v5_6_4/snapshot.status.json
  242. +28 −0 src/rest-spec/v5_6_4/snapshot.verify_repository.json
  243. +44 −0 src/rest-spec/v5_6_4/suggest.json
  244. +35 −0 src/rest-spec/v5_6_4/tasks.cancel.json
  245. +23 −0 src/rest-spec/v5_6_4/tasks.get.json
  246. +45 −0 src/rest-spec/v5_6_4/tasks.list.json
  247. +96 −0 src/rest-spec/v5_6_4/termvectors.json
  248. +94 −0 src/rest-spec/v5_6_4/update.json
  249. +176 −0 src/rest-spec/v5_6_4/update_by_query.json
@@ -1,3 +1,5 @@
out
node_modules
.vscode
.DS_Store
package-lock.json
@@ -0,0 +1,42 @@
/*jslint esversion: 6*/
const del = require('del');
const fs = require('fs');
const jsesc = require('jsesc');
(function () {
'use strict';

const SRC_ROOT = `${__dirname}/../src/rest-spec`;

del.sync(`${SRC_ROOT}/**/*.ts`);
fs.writeFileSync(`${SRC_ROOT}/json.d.ts`, 'declare module "*.json" { const value: any; export default value; }');

const requireDir = require('require-dir');
const restSpec = requireDir('../src/rest-spec', {recurse: true});

let rootIndex = '';

let versions = Object.keys(restSpec);
versions.forEach(version => {
rootIndex += `import * as ${version} from './${version}';\n`;
let endpointNames = Object.keys(restSpec[version]);
let versionIndex = endpointNames
.map(endpointName => `const def_${endpointName.replace(/\./g, '_')} = JSON.parse('${jsesc(JSON.stringify(restSpec[version][endpointName]))}')`)
.join(';\n');

versionIndex += `\n\nexport default {\n`;
versionIndex += endpointNames
.map(endpointName => ` '${endpointName}': def_${endpointName.replace(/\./g, '_')}` +
(endpointName != '_common' ? `['${endpointName}']` : ''))
.join(',\n');
versionIndex += '\n}';
fs.writeFileSync(`${SRC_ROOT}/${version}/index.ts`, versionIndex, 'utf-8');
});

rootIndex += `\nexport default {\n`;
rootIndex += versions
.map(version => ` '${version.substring(1).replace(/_/g, '.')}': ${version}`)
.join(',\n');
rootIndex += '\n}';

fs.writeFileSync(`${SRC_ROOT}/index.ts`, rootIndex, 'utf-8');
}());
@@ -85,19 +85,24 @@
"test": "npm run compile && node ./node_modules/vscode/bin/test"
},
"dependencies": {
"jsonc-parser": "^0.3.0",
"request": "^2.79.0",
"path": "^0.12.7",
"json-markup": "^1.1.0",
"copy-paste": "^1.3.0",
"fast-router": "^1.0.3",
"json-markup": "^1.1.0",
"jsonc-parser": "^0.3.0",
"mustache": "^2.3.0",
"path": "^0.12.7",
"request": "^2.79.0",
"semver-closest": "^0.1.2",
"strip-json-comments": "^2.0.1"
},
"devDependencies": {
"typescript": "^2.5.2",
"vscode": "^1.1.5",
"mocha": "^3.5.0",
"@types/mocha": "^2.2.42",
"@types/node": "^7.0.43",
"@types/mocha": "^2.2.42"
"del": "^3.0.0",
"jsesc": "^2.5.1",
"mocha": "^3.5.0",
"require-dir": "^0.3.2",
"typescript": "^2.5.2",
"vscode": "^1.1.5"
}
}
}
@@ -0,0 +1,109 @@
'use script';

import * as vscode from 'vscode';
import * as request from 'request';
import { Range } from 'vscode';
import url = require('url');
import { Router } from 'fast-router';
import closestSemver = require('semver-closest')

const PATH_REGEX = /^(GET|POST|PUT|DELETE|HEAD) +(.+)$/;

export class ElasticCompletionItemProvider implements vscode.CompletionItemProvider {

private readonly context: vscode.ExtensionContext;
private readonly restSpec: any;

constructor(context: vscode.ExtensionContext) {
this.context = context;

this.restSpec = this.buildRestSpecRouter();
}

private buildRestSpecRouter() {
const restSpec = require('./rest-spec').default;
const versions = Object.keys(restSpec);
const result = {};

versions.forEach(version => {
const endpointDescriptions = restSpec[version].default;
const common = endpointDescriptions._common;
delete endpointDescriptions._common;
const endpointNames = Object.keys(endpointDescriptions);

const router = new Router();
result[version] = router;

endpointNames.forEach(endpointName => {
const endpointDescription = endpointDescriptions[endpointName];
const paths = endpointDescription.url.paths.map(path => path.replace(/\{/g, ':').replace(/\}/g, ''));
const methods = endpointDescription.methods;
methods.forEach(method => paths
.forEach(path => router
.addRoute(`/${method}/${path}`, endpointDescription)));
});
});

return result;
}

provideCompletionItems(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken): vscode.ProviderResult<vscode.CompletionItem[] | vscode.CompletionList> {
return this.getElasticVersion().then(esVersion => {
if (!esVersion)
return [];

let apiVersion = closestSemver(esVersion, Object.keys(this.restSpec));
console.log(apiVersion);
return [];
});
/*let restSpec = this.restSpec[]
let currentLine = this.getCurrentLine(document, position);
let parsedPath = this.parsePath(currentLine);
if (parsedPath)
return this.providePathCompletionItems(parsedPath, apiVersion);
return [ ];*/
}

private getCurrentLine(document: vscode.TextDocument, position: vscode.Position): string {
return document.getText(new Range(position.with({ character: 0 }), position));
}


private providePathCompletionItems(parsedPath: RegExpMatchArray, restSpec: any): vscode.ProviderResult<vscode.CompletionItem[] | vscode.CompletionList> {
let path = parsedPath[2].trim();
return [];
}

private parsePath(text: string): RegExpMatchArray {
return PATH_REGEX.exec(text);
}

//private lookupEndpoint(esVersion: string, )

private async getElasticVersion(): Promise<string> {
const host: string = this.context.workspaceState.get("elastic.host", null);
const requestUrl: string = url.format({ host, pathname: '/', protocol: 'http' });
return new Promise<string>((resolve, reject) => {
request(<request.UrlOptions & request.CoreOptions>{
url: requestUrl, method: 'GET', body: '/',
headers: { 'Content-Type': 'application/json' }
}, (error, response, body) => {
try {
resolve(JSON.parse(body).version.number);
} catch(e) {
resolve(null);
}
})
});
}
/*resolveCompletionItem?(item: vscode.CompletionItem, token: vscode.CancellationToken): vscode.ProviderResult<vscode.CompletionItem> {
throw new Error("Method not implemented.");
}*/

}



@@ -12,6 +12,7 @@ import { ElasticCodeLensProvider } from './ElasticCodeLensProvider'
import { ElasticContentProvider } from './ElasticContentProvider'
import { ElasticDecoration } from './ElasticDecoration'
import { ElasticMatch } from './ElasticMatch'
import { ElasticCompletionItemProvider } from './ElasticCompletionItemProvider'

// import { JSONCompletionItemProvider } from "./JSONCompletionItemProvider";

@@ -116,6 +117,8 @@ export function activate(context: vscode.ExtensionContext) {
}
}));

context.subscriptions.push(vscode.languages.registerCompletionItemProvider(languages, new ElasticCompletionItemProvider(context), '/'));

}

async function setHost(context: vscode.ExtensionContext): Promise<string> {
@@ -0,0 +1,7 @@
import * as v2_4_6 from './v2_4_6';
import * as v5_6_4 from './v5_6_4';

export default {
'2.4.6': v2_4_6,
'5.6.4': v5_6_4
}
@@ -0,0 +1 @@
declare module "*.json" { const value: any; export default value; }
@@ -0,0 +1,52 @@
{
"bulk": {
"documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/2.4/docs-bulk.html",
"methods": ["POST", "PUT"],
"url": {
"path": "/_bulk",
"paths": ["/_bulk", "/{index}/_bulk", "/{index}/{type}/_bulk"],
"parts": {
"index": {
"type" : "string",
"description" : "Default index for items which don't provide one"
},
"type": {
"type" : "string",
"description" : "Default document type for items which don't provide one"
}
},
"params": {
"consistency": {
"type" : "enum",
"options" : ["one", "quorum", "all"],
"description" : "Explicit write consistency setting for the operation"
},
"refresh": {
"type" : "boolean",
"description" : "Refresh the index after performing the operation"
},
"routing": {
"type" : "string",
"description" : "Specific routing value"
},
"timeout": {
"type" : "time",
"description" : "Explicit operation timeout"
},
"type": {
"type" : "string",
"description" : "Default document type for items which don't provide one"
},
"fields": {
"type": "list",
"description" : "Default comma-separated list of fields to return in the response for updates"
}
}
},
"body": {
"description" : "The operation definition and data (action-data pairs), separated by newlines",
"required" : true,
"serialize" : "bulk"
}
}
}
@@ -0,0 +1,41 @@
{
"cat.aliases": {
"documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/2.4/cat-alias.html",
"methods": ["GET"],
"url": {
"path": "/_cat/aliases",
"paths": ["/_cat/aliases", "/_cat/aliases/{name}"],
"parts": {
"name": {
"type" : "list",
"description" : "A comma-separated list of alias names to return"
}
},
"params": {
"local": {
"type" : "boolean",
"description" : "Return local information, do not retrieve the state from master node (default: false)"
},
"master_timeout": {
"type" : "time",
"description" : "Explicit operation timeout for connection to master node"
},
"h": {
"type": "list",
"description" : "Comma-separated list of column names to display"
},
"help": {
"type": "boolean",
"description": "Return help information",
"default": false
},
"v": {
"type": "boolean",
"description": "Verbose mode. Display column headers",
"default": false
}
}
},
"body": null
}
}
@@ -0,0 +1,46 @@
{
"cat.allocation": {
"documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/2.4/cat-allocation.html",
"methods": ["GET"],
"url": {
"path": "/_cat/allocation",
"paths": ["/_cat/allocation", "/_cat/allocation/{node_id}"],
"parts": {
"node_id": {
"type": "list",
"description": "A comma-separated list of node IDs or names to limit the returned information"
}
},
"params": {
"bytes": {
"type": "enum",
"description" : "The unit in which to display byte values",
"options": [ "b", "k", "m", "g" ]
},
"local": {
"type" : "boolean",
"description" : "Return local information, do not retrieve the state from master node (default: false)"
},
"master_timeout": {
"type" : "time",
"description" : "Explicit operation timeout for connection to master node"
},
"h": {
"type": "list",
"description" : "Comma-separated list of column names to display"
},
"help": {
"type": "boolean",
"description": "Return help information",
"default": false
},
"v": {
"type": "boolean",
"description": "Verbose mode. Display column headers",
"default": false
}
}
},
"body": null
}
}

0 comments on commit ad87291

Please sign in to comment.
You can’t perform that action at this time.