-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
Documentation for Saved Objects API #19513
Conversation
Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
💚 Build Succeeded |
but not limited to dashboards, visualizations, and index patterns. | ||
|
||
Traditionally, developers would perform this level of integration by writing | ||
documents directly to the `.kibana` index. *Do not do this!* Writing directly |
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.
how do we reconcile this with the experimental flag?
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.
I don't think we do. We don't have a stable way to programmatically manage saved objects.
|
||
`type` (required):: | ||
(string) Valid options, include: `visualization`, `dashboard`, `search`, `config`, and `timelion-sheet` | ||
|
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.
Should index-pattern
be in that list of valid options? I'm hoping it would.
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, index-pattern
is valid. I'll add it everywhere we have a list like this.
|
||
`type` (required):: | ||
(string) Valid options, include: `visualization`, `dashboard`, `search`, `config`, and `timelion-sheet` | ||
|
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.
No index-pattern
?
==== Examples | ||
|
||
The following example deletes an index pattern object with an ID of `my-pattern` | ||
|
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
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.
I know the Platform team is researching API specs, such as OpenAPI/Swagger. If we plan on exploring that route, I found https://github.com/Swagger2Markup/swagger2markup, which converts a Swagger spec to AsciiDoc. If nothing else, it might be a decent starting point for us. I'm not suggesting we tackle it for this PR, but it's something to think about in the future before we hand-write too many of these.
`type` (required):: | ||
(string) Valid options, include: `visualization`, `dashboard`, `search`, `config`, and `timelion-sheet` | ||
|
||
`id` (required):: |
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.
Do you think it's worthwhile to point out that this isn't the ES _id
? This tripped me up at first because I kept forgetting that the document id is derived from this id
The following example attempts to find index patterns with titles that start | ||
with `my`: | ||
|
||
[source,js] |
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.
What do you think about adding an example showing how to specify multiple search_fields
/fields
? I know there are a few different patterns for doing this, so having it documented could be helpful
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.
I've pushed a change that clarifies this behavior, but I think it really belongs in some top level "API conventions" documentation since its not unique to the saved objects API. But we can address that separately.
==== Path Parameters | ||
|
||
`type` (required):: | ||
(string) Valid options, include: `visualization`, `dashboard`, `search`, `config`, and `timelion-sheet` |
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.
The type
and id
path parameters are used and described in a few of these API endpoints. What do you think about extracting these descriptions into reusable AsciiDoc attributes? It could prevent these from getting out of sync in the future.
`per_page` (optional):: | ||
(number) The number of objects to return per page | ||
`page` (optional):: | ||
(number) The page of objects to return |
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.
Is there a way to set per_page
to get all objects? Do I just set it to some huge number, or zero means all?
If I find with per_page
= 10, do I start with page
= 0? Or page
= 1?
Am I guaranteed that when I get page 2 the list won't have changed? I'm trying to recall how the scroll api worked.
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.
Is there a way to set per_page to get all objects? Do I just set it to some huge number, or zero means all?
No, there is no way to do this. You'd need to use a scan/scroll like streaming interface for that, which we don't have at the moment.
If I find with per_page = 10, do I start with page = 0? Or page = 1?
It starts with page 1. I've never encountered an API that zero indexes pages, have you?
Am I guaranteed that when I get page 2 the list won't have changed? I'm trying to recall how the scroll api worked.
No, this is not a scan/scroll-like interface. It's just classic pagination, which can change as you navigate. I can add a note about that.
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.
I've pushed a note that clarifies this.
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.
Looks like there's a default per_page of 20? I just did a find with no parameters and got this;
{"page":1,"per_page":20,"total":418,"saved_objects":
docs/api/saved-objects/get.asciidoc
Outdated
|
||
`type` (required):: | ||
(string) Valid options, include: `visualization`, `dashboard`, `search`, `config`, and `timelion-sheet` | ||
|
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.
index-pattern
LGTM for getting a first pass in. I think in the future we could add info on how to auth/why there's a kbn-xsrf header. And then in the copy as curl section |
It looks like if I needed to export everything and re-create it in a new Kibana instance I could do the |
Another future thought is to publish our clients, or move them somewhere plugins can use. And document those APIs too. |
I've pushed updates to address all the feedback, along with the notes below. Can I get another pass?
This is awesome! We'll definitely take a look at that in the near future.
Yes, I think we need an API conventions doc. I've created an issue for that: #19553
What OS/version of curl do you see this on? I don't get any such warnings on macos. In any case, that isn't from this PR itself, so we won't block on it.
Since We have an issue for a generic import/export API, and we'll want to document it as well: #16831
For sure! |
💚 Build Succeeded |
LGTM! |
* Adds documentation for Saved Objects API Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co> * [DOCS] Moved Rest APIs in navigation * docs: revise rest api intro * docs: revise create object api details * docs: revise saved object api intro * docs: revise delete saved object api details * docs: remove newline character from api response * docs: get saved object api details * docs: update saved object api details * docs: fix title attribute in saved object api examples * docs: bulk-get saved object api details * docs: find saved object api details * docs: add index-pattern to valid types in api * docs: clarify sending multiple values in api * docs: note that savedObjects.find is not safe for export
* Adds documentation for Saved Objects API Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co> * [DOCS] Moved Rest APIs in navigation * docs: revise rest api intro * docs: revise create object api details * docs: revise saved object api intro * docs: revise delete saved object api details * docs: remove newline character from api response * docs: get saved object api details * docs: update saved object api details * docs: fix title attribute in saved object api examples * docs: bulk-get saved object api details * docs: find saved object api details * docs: add index-pattern to valid types in api * docs: clarify sending multiple values in api * docs: note that savedObjects.find is not safe for export
Can I use the create object endpoint to create a dashboard and populate it with visuals that already exist? I am able to create an empty dashboard by posting a json payload with an attributes object that contains a title and description. However, I can't seem to figure out how to pass in the panelsJSON array to fill in the dashboard. Is this possible? |
This is an initial pass on the saved object API, which will be the first API formally documented under the Kibana REST API. There is plenty of additional stuff we could add, like more examples, more structured ways to indicate error messages and status codes, etc.
My intention here is simply to get things started, since not documented these APIs at all is becoming a burden.
To test this PR, simply run
node scripts/docs.js --open
, which should open a new tab in your browser.Supersedes #16726
Closes #14871