1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
22 use
("/list", new APIList(config
))
23 use
("/random", new APIRandom(config
))
24 use
("/search", new APISearch(config
))
26 use
("/entity/:id", new APIEntity(config
))
27 use
("/doc/:id", new APIEntityDoc(config
))
28 use
("/code/:id", new APIEntityCode(config
))
29 use
("/lin/:id", new APIEntityLinearization(config
))
30 use
("/defs/:id", new APIEntityDefs(config
))
31 use
("/intros/:id", new APIEntityIntros(config
))
32 use
("/redefs/:id", new APIEntityRedefs(config
))
33 use
("/meta/:id", new APIEntityMetadata(config
))
34 use
("/all/:id", new APIEntityAll(config
))
36 use
("/ancestors/:id", new APIEntityAncestors(config
))
37 use
("/parents/:id", new APIEntityParents(config
))
38 use
("/children/:id", new APIEntityChildren(config
))
39 use
("/descendants/:id", new APIEntityDescendants(config
))
41 use
("/uml/:id", new APIEntityUML(config
))
42 use
("/graph/inheritance/:id", new APIInheritanceGraph(config
))
44 use
("/catalog/packages/", new APICatalogPackages(config
))
45 use
("/catalog/stats", new APICatalogStats(config
))
46 use
("/catalog/tags", new APICatalogTags(config
))
47 use
("/catalog/tag/:tid", new APICatalogTag(config
))
48 use
("/catalog/person/:pid", new APICatalogPerson(config
))
49 use
("/catalog/person/:pid/maintaining", new APICatalogMaintaining(config
))
50 use
("/catalog/person/:pid/contributing", new APICatalogContributing(config
))
52 use
("/ini/desc/:id", new APIIniDesc(config
))
53 use
("/ini/git/:id", new APIIniGit(config
))
54 use
("/ini/clone/:id", new APIIniClone(config
))
55 use
("/ini/issues/:id", new APIIniIssues(config
))
56 use
("/ini/maintainer/:id", new APIIniMaintainer(config
))
57 use
("/ini/contributors/:id", new APIIniContributors(config
))
58 use
("/ini/license/:id", new APIIniLicense(config
))
59 use
("/ini/license-file/:id", new APIIniLicenseFile(config
))
60 use
("/ini/license-content/:id", new APIIniLicenseFileContent(config
))
61 use
("/ini/contrib-file/:id", new APIIniContribFile(config
))
62 use
("/ini/contrib-content/:id", new APIIniContribFileContent(config
))
66 # An API Handler that use a DocCommand to respond
67 abstract class APICommand
70 # Return the doc command to apply for self
71 fun command
: DocCommand is abstract
73 redef fun get
(req
, res
) do
74 var command
= self.command
75 var status
= command
.http_init
(req
)
76 if status
isa CmdError then
77 res
.api_error
(status
.http_status_code
, status
.to_s
)
80 res
.api_json
(req
, command
.to_json
)
88 # Example: `GET /list?kind=modules?limit=10`
92 redef fun command
do return new CmdModelEntities(config
.model
)
95 # Return a random list of MEntities.
97 # Example: `GET /random?kind=modules&limit=10`
101 redef fun command
do return new CmdRandomEntities(config
.model
)
104 # Search mentities from a cmd string.
106 # Example: `GET /search?q=Arr`
110 redef fun command
do return new CmdCatalogSearch(config
.model
, config
.catalog
)
115 # Return the JSON representation of a MEntity.
117 # Example: `GET /entity/core::Array`
121 redef fun command
do return new CmdEntity(config
.model
)
124 # Return the full MDoc of a MEntity.
126 # Example: `GET /entity/core::Array/doc`
130 redef fun command
do return new CmdComment(config
.model
)
133 # List MEntity ancestors
135 # Example: `GET /ancestors/core::Array`
136 class APIEntityAncestors
139 redef fun command
do return new CmdAncestors(config
.model
, config
.mainmodule
)
142 # List MEntity parents
144 # Example: `GET /parents/core::Array`
145 class APIEntityParents
148 redef fun command
do return new CmdParents(config
.model
, config
.mainmodule
)
151 # List MEntity children
153 # Example: `GET /children/core::Array`
154 class APIEntityChildren
157 redef fun command
do return new CmdChildren(config
.model
, config
.mainmodule
)
160 # List MEntity descendants
162 # Example: `GET /descendants/core::Array`
163 class APIEntityDescendants
166 redef fun command
do return new CmdDescendants(config
.model
, config
.mainmodule
)
169 # Linearize super definitions of a MClassDef or a MPropDef if any.
171 # Example: `GET /linearization/core::Array`
172 class APIEntityLinearization
175 redef fun command
do return new CmdLinearization(config
.model
, config
.mainmodule
)
178 # List definitions of a MEntity.
180 # Example: `GET /defs/core::Array`
184 redef fun command
do return new CmdFeatures(config
.model
)
187 # List intro definitions of a MEntity.
189 # Example: `GET /intros/core::Array`
190 class APIEntityIntros
193 redef fun command
do return new CmdIntros(config
.model
, config
.mainmodule
)
196 # List redef definitions of a MEntity.
198 # Example: `GET /redefs/core::Array`
199 class APIEntityRedefs
202 redef fun command
do return new CmdRedefs(config
.model
, config
.mainmodule
)
205 # List all definitions accessible from a MEntity.
207 # Example: `GET /all/core::Array`
211 redef fun command
do return new CmdAllProps(config
.model
, config
.mainmodule
)
214 # Return the source code of MEntity.
216 # Example: `GET /code/core::Array`
220 redef fun command
do return new CmdEntityCode(config
.model
, config
.modelbuilder
)
223 # Return the UML diagram for MEntity.
225 # Example: `GET /uml/core::Array`
229 redef fun command
do return new CmdUML(config
.model
, config
.mainmodule
)
232 # Return the inheritance graph for MEntity.
234 # Example: `GET /inheritance/core::Array`
235 class APIInheritanceGraph
238 redef fun command
do return new CmdInheritanceGraph(config
.model
, config
.mainmodule
)
243 # Get all the packages from the catalog using pagination
245 # `GET /packages?p=1&n=10`: get the list of catalog by page
246 class APICatalogPackages
249 redef fun command
do return new CmdCatalogPackages(config
.model
, config
.catalog
)
252 # Get the catalog statistics
254 # `GET /stats`: return the catalog statistics
255 class APICatalogStats
258 redef fun command
do return new CmdCatalogStats(config
.model
, config
.catalog
)
261 # Get the package metadata
263 # `GET /:id/metadata`: return a paginated list of packages
264 class APIEntityMetadata
267 redef fun command
do return new CmdMetadata(config
.model
)
270 # Get all the tags from the catalog
272 # `GET /tags`: the list of tags associated with their number of packages
276 redef fun command
do return new CmdCatalogTags(config
.model
, config
.catalog
)
279 # Get the packages related to a tag
281 # `GET /tag/:tid?p=1&n=10`: return a paginated list of packages
285 redef fun command
do return new CmdCatalogTag(config
.model
, config
.catalog
)
288 # Get a person existing in the catalog
290 # `GET /person/:pid`: get the person with `pid`
291 class APICatalogPerson
294 redef fun command
do return new CmdCatalogPerson(config
.model
, config
.catalog
)
297 # Get the list of mpackages maintained by a person
299 # `GET /person/:pid/maintaining?p=1&n=10`: return a paginated list of packages
300 class APICatalogMaintaining
303 redef fun command
do return new CmdCatalogMaintaining(config
.model
, config
.catalog
)
306 # Get the list of mpackages contributed by a person
308 # `GET /person/:pid/contributing?p=1&n=10`: return a paginated list of packages
309 class APICatalogContributing
312 redef fun command
do return new CmdCatalogContributing(config
.model
, config
.catalog
)
317 # Get the package description from the ini file
319 # `GET /ini/desc/:pid`: return the package description
323 redef fun command
do return new CmdIniDescription(config
.model
)
326 # Get the package Git URL from the ini file
328 # `GET /ini/git/:pid`: return the package Git URL
332 redef fun command
do return new CmdIniGitUrl(config
.model
)
335 # Get the package Git clone command from the ini file
337 # `GET /ini/clone/:pid`: return the package Git clone command
341 redef fun command
do return new CmdIniCloneCommand(config
.model
)
344 # Get the package issues URL from the ini file
346 # `GET /ini/issues/:pid`: return the package issues URL
350 redef fun command
do return new CmdIniIssuesUrl(config
.model
)
353 # Get the package maintainer from the ini file
355 # `GET /ini/maintainer/:pid`: return the package maintainer
356 class APIIniMaintainer
359 redef fun command
do return new CmdIniMaintainer(config
.model
)
362 # Get the package contributors from the ini file
364 # `GET /ini/clone/:pid`: return the package contributors
365 class APIIniContributors
368 redef fun command
do return new CmdIniContributors(config
.model
)
371 # Get the package license from the ini file
373 # `GET /ini/clone/:pid`: return the package license
377 redef fun command
do return new CmdIniLicense(config
.model
)
380 # Get the package license file
382 # `GET /ini/license-file/:pid`: return the package license file
383 class APIIniLicenseFile
386 redef fun command
do return new CmdLicenseFile(config
.model
)
389 # Get the package contrib file
391 # `GET /ini/contrib-file/:pid`: return the package contrib file
392 class APIIniContribFile
395 redef fun command
do return new CmdContribFile(config
.model
)
398 # Get the package license file content
400 # `GET /ini/license-file/:pid`: return the package license file content
401 class APIIniLicenseFileContent
404 redef fun command
do return new CmdLicenseFileContent(config
.model
)
407 # Get the package contrib file content
409 # `GET /ini/contrib-file/:pid`: return the package contrib file content
410 class APIIniContribFileContent
413 redef fun command
do return new CmdContribFileContent(config
.model
)