New API - npolar/api.npolar.no GitHub Wiki
There's an API for that! Use the Service API to create new APIs.
For JSON APIs, powered by CoucDB and Elasticsearch, creating a new endpoint is simply done by a PUT of a service document:
$ curl -niXPUT https://api.npolar.no/service/project-api -H "Content-Type: application/json" -d@seed/service/project-api.json
Notice the -n
flag for using .netrc
authentication with curl.
In production environments, you will also have to restart your ruby application server.
$ sudo su - api
# service api restart
When you PUT a service document, the new API is bootstrapped.
Provided you use CouchDB and Elasticsearch, the following happens
- CouchDB database is created
- Elasticsearch index, mapping, and river for indexing (CouchDB _changes stream) is created
Bootstrapping is trigged by the Service.after_lambda, that in turns calls Bootstrap#bootstrap(service)
Service document schema: http://api.npolar.no/schema/api Service document example: https://github.com/npolar/api.npolar.no/blob/master/seed/service/editlog-api.json
The Elasticsearch index document
The mapping ...
See also Validation for how to enable JSON schema validation on POST and PUT.
To remap and/or reindex Elasticsearch, do a new PUT of the service document. This will DELETE the current mapping and index and start