-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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
export { SavedObjectsClient } from './saved_objects_client'; | ||
export { SavedObjectRegistryProvider } from './saved_object_registry'; | ||
export { SavedObjectsClientProvider } from './saved_objects_client_provider'; | ||
export { RedirectWhenMissingProvider } from './redirect_when_missing_provider'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
|
||
export const createCreateRoute = (prereqs) => { | ||
return { | ||
path: '/api/kibana/saved_objects/{type}/{id?}', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thoughts on removing kibana from the api route? with the goal of eventually opening this api up to all applications
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I like that.
} | ||
|
||
delete() { | ||
return this.cient.delete(this.type, this.id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cient = client
This could replace the settings API. |
savedObjectsClient._request('GET', '/api/path', params).then(() => { | ||
done('should have thrown'); | ||
}).catch(e => { | ||
expect(e.message).to.eql('404 Response'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
errors return the underlying query to the browser, thoughts on logging this instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
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 <[email protected]>
Signed-off-by: Tyler Smalley <[email protected]>
Signed-off-by: Tyler Smalley <[email protected]>
Signed-off-by: Tyler Smalley <[email protected]>
Signed-off-by: Tyler Smalley <[email protected]>
Signed-off-by: Tyler Smalley <[email protected]>
Signed-off-by: Tyler Smalley <[email protected]>
401237a
to
af59a5c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is breaking the functional tests somehow... LGTM once they are passing (and not taking an hour to run)
Signed-off-by: Tyler Smalley <[email protected]>
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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-i
to 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-pattern
Response:
Read
Route:
GET /api/saved_objects/{type}/{id}
cURL:
curl "http://localhost:5601/api/saved_objects/index-pattern/AVwXs-2htCUMy4H_zXXl"
Response:
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_zXXl
Response:
Delete
Route:
DELETE /api/saved_objects/{type}/{id}
cURL:
curl -X DELETE http://localhost:5601/api/saved_objects/index-pattern/AVwXs-2htCUMy4H_zXXl
Response: 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: