Adds an API for managing saved objects#11632
Conversation
|
As soon as this is in I will move #10858 over to it. |
029aeab to
6d97a1c
Compare
8150be5 to
c96a91e
Compare
src/ui/public/saved_objects/index.js
Outdated
There was a problem hiding this comment.
tests are failing on this,
ERROR in ./src/ui/public/saved_objects/index.js
Module not found: Error: Cannot resolve 'file' or 'directory' ./redirect_when_missing_provider in /var/lib/jenkins/workspace/elastic+kibana+pull-request+multijob-intake/src/ui/public/saved_objects
@ ./src/ui/public/saved_objects/index.js 34:38-81
c96a91e to
c54f2c7
Compare
There was a problem hiding this comment.
thoughts on removing kibana from the api route? with the goal of eventually opening this api up to all applications
|
This could replace the settings API. |
There was a problem hiding this comment.
errors return the underlying query to the browser, thoughts on logging this instead?
There was a problem hiding this comment.
Thought on eliminating exposing of the ES query entirely? Logging can be done by enabling elaticsearch.logQueries with --verbose. Logging things like 404's without verbose or an elevated log level seems a little noisy.
|
With types going away, thoughts on allowing |
|
@jbudz, I am all for allowing direct |
|
@jbudz, we're now handling version correctly. |
|
I kind of like the |
Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
401237a to
af59a5c
Compare
spalger
left a comment
There was a problem hiding this comment.
This is breaking the functional tests somehow... LGTM once they are passing (and not taking an hour to run)
Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
POST /api/saved_objects/{type}
GET /api/saved_objects/{type}/{id}
PUT /api/saved_objects/{type}/{id}
DELETE /api/saved_objects/{type}/{id}
GET /api/saved_objects/{type?}
|
5.x: d2500c3 |
|
🎉 🎉 🎉 🎉 |
|
Hell yeah! |
| expect(savedObjectsClient.find.calledOnce).to.be(true); | ||
|
|
||
| const options = savedObjectsClient.find.getCall(0).args[0]; | ||
| expect(options).to.eql({ perPage: 20, page: 1, fields: 'title' }); |
There was a problem hiding this comment.
sometimes I see fields and sometimes I see searchFields. Which one is correct? Or can both be used?
There was a problem hiding this comment.
You should use fields if you want to limit the response. For instance, if you are only interested in title, and description.
searchFields is used in conjunction with search. It allows you to define which fields to search against. Omitting searchFields will search against all fields. You can also define weights, like title^5: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-simple-query-string-query.html
POST /api/saved_objects/{type}
GET /api/saved_objects/{type}/{id}
PUT /api/saved_objects/{type}/{id}
DELETE /api/saved_objects/{type}/{id}
GET /api/saved_objects/{type?}
|
I've written an With this and the script from #3709 (comment), I can now deploy Kibana in a fully declarative fashion without having to load anything manually into it. |
|
This issue is also relevant. If you would prefer a method for loading dashboards and indexpatterns from the file-system (for use with Chef, Puppet, Salt, etc) please vouch for it here: |
API Overview
For brevity, I have simplified the cURL commands to exclude the necessary headers. You will need to include the following:
-H "Content-Type: application/json" -H "kbn-xsrf: true". I would also suggest adding-ito confirm the response headers.Create
Route:
POST /api/saved_objects/{type}cURL:
curl -X POST -d '{ "attributes": { "title": "Test pattern" } }' http://localhost:5601/api/saved_objects/index-patternResponse:
{ "type":"index-pattern", "id":"AVwXs-2htCUMy4H_zXXl", "version":1, "attributes":{ "title":"Test pattern" } }Read
Route:
GET /api/saved_objects/{type}/{id}cURL:
curl "http://localhost:5601/api/saved_objects/index-pattern/AVwXs-2htCUMy4H_zXXl"Response:
{ "id":"AVwXs-2htCUMy4H_zXXl", "type":"index-pattern", "version":1, "attributes":{ "title":"Test pattern" } }Update
Route:
PUT /api/saved_objects/{type}/{id}cURL:
curl -X PUT -d '{ "version": 1, "attributes": { "title": "Updated title" } }' http://localhost:5601/api/saved_objects/index-pattern/AVwXs-2htCUMy4H_zXXlResponse:
{ "id":"AVwXs-2htCUMy4H_zXXl", "type":"index-pattern", "version":2, "attributes":{ "title":"Updated title" } }Delete
Route:
DELETE /api/saved_objects/{type}/{id}cURL:
curl -X DELETE http://localhost:5601/api/saved_objects/index-pattern/AVwXs-2htCUMy4H_zXXlResponse: Boolean based on success. We return an error if the document can not be found.
Find
Route:
GET /api/saved_objects/{type?}Query parameters (optional):
cURL:
curl "http://localhost:5601/api/saved_objects?fields=title&search=tyler"Response:
{ "data":[ { "id":"b7aff090-346d-11e7-9d21-53e7c9e02e64", "type":"search", "version":1, "attributes": { "title":"s1" } } ], "total":1, "per_page":20, "page":1 }