Skip to content

Commit 2484c2a

Browse files
committed
Add support for create api when there is no specifying id
Signed-off-by: Yu Jin <112784385+yujin-emma@users.noreply.github.com>
1 parent 191b3db commit 2484c2a

File tree

1 file changed

+179
-43
lines changed

1 file changed

+179
-43
lines changed

docs/openapi/saved_objects/saved_objects.yml

Lines changed: 179 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,166 @@ info:
99
tags:
1010
- name: saved objects
1111
description: Manage Dashboards saved objects, including dashboards, visualizations, saved search, and more.
12+
components:
13+
parameters:
14+
type:
15+
name: type
16+
in: path
17+
description: The type of SavedObject to retrieve.
18+
required: true
19+
schema:
20+
type: string
21+
enum:
22+
- dashboard
23+
- config
24+
- index-pattern
25+
example: dashboard
26+
id:
27+
name: id
28+
in: path
29+
description: Unique id of the saved object.
30+
required: true
31+
schema:
32+
type: string
33+
example: I2CFyW_27a48aa0-b274-11ef-b63c-9f43fceaea0c_7adfa750-4c81-11e8-b3d7-01146121b73d
34+
schemas:
35+
400_bad_request:
36+
title: Bad request
37+
type: object
38+
required:
39+
- error
40+
- message
41+
- statusCode
42+
properties:
43+
error:
44+
type: string
45+
enum:
46+
- Bad Request
47+
message:
48+
type: string
49+
statusCode:
50+
type: integer
51+
enum:
52+
- 400
1253
paths:
54+
/api/saved_objects/{type}:
55+
post:
56+
tags:
57+
- saved objects
58+
summary: Create a new saved object without specifying an ID
59+
parameters:
60+
- $ref: '#/components/parameters/type'
61+
- in: query
62+
name: overwrite
63+
description: If set to true, will overwrite the existing saved object with same type and id.
64+
schema:
65+
type: boolean
66+
requestBody:
67+
required: true
68+
content:
69+
application/json:
70+
schema:
71+
type: object
72+
required:
73+
- attributes
74+
properties:
75+
attributes:
76+
type: object
77+
description: The metadata of the saved object to be created, and the object is not validated.
78+
migrationVersion:
79+
type: object
80+
description: The information about the migrations that have been applied to this saved object to be created.
81+
references:
82+
description: List of objects that describe other saved objects the created object references.
83+
type: array
84+
items:
85+
type: object
86+
properties:
87+
id:
88+
type: string
89+
name:
90+
type: string
91+
type:
92+
type: string
93+
initialNamespaces:
94+
description: Namespaces that this saved object exists in. This attribute is only used for multi-namespace saved object types.
95+
type: array
96+
items:
97+
type: string
98+
workspaces:
99+
type: array
100+
items:
101+
type: string
102+
description: Workspaces that this saved object exists in.
103+
examples:
104+
indexPattern:
105+
summary: Example of creating an index pattern saved object
106+
value:
107+
attributes:
108+
title: 'my-index-pattern'
109+
fields: '[{"count":"1","name":"@timestamp","searchable":"true"}]'
110+
references:
111+
- id: '51339560-1d7c-11ef-b757-55fac6c80d9a'
112+
name: 'dataSource'
113+
type: 'data-source'
114+
vegaVisualization:
115+
summary: Example of creating a Vega visualization saved object
116+
value:
117+
attributes:
118+
title: 'my-vega-visualization'
119+
visState: '{"title":"vegaVisualization","type":"vega","aggs":[]}}'
120+
uiStateJSON: '{}'
121+
description: ''
122+
version: 1
123+
kibanaSavedObjectMeta: {
124+
searchSourceJSON: '{"query":{"language":"kuery","query":""},"filter":[]}'
125+
}
126+
references:
127+
- id: '51339560-1d7c-11ef-b757-55fac6c80d9a'
128+
name: 'dataSource'
129+
type: 'data-source'
130+
dashboards:
131+
summary: Example of creating a dashboard saved object
132+
value:
133+
attributes:
134+
title: 'Revenue Dashboard'
135+
description: 'Revenue dashboard'
136+
panelsJSON: '[{"version":"2.9.0","gridData":{"x":0,"y":0,"w":24,"h":15,"i":"5db1d75d-f680-4869-a0e8-0f2b8b05b99c"},"panelIndex":"5db1d75d-f680-4869-a0e8-0f2b8b05b99c","embeddableConfig":{},"panelRefName":"panel_0"}]'
137+
optionsJSON: '{"hidePanelTitles":false,"useMargins":true}'
138+
version: 1
139+
timeRestore: true
140+
kibanaSavedObjectMeta: {
141+
searchSourceJSON: '{"query":{"language":"kuery","query":""},"filter":[]}'
142+
}
143+
references:
144+
- id: '37cc8650-b882-11e8-a6d9-e546fe2bba5f'
145+
name: 'panel_0'
146+
type: 'visualization'
147+
responses:
148+
'200':
149+
description: The creation request is successful
150+
content:
151+
application/json:
152+
schema:
153+
type: object
154+
'400':
155+
description: Bad request
156+
content:
157+
application/json:
158+
schema:
159+
$ref: '#/components/schemas/400_bad_request'
160+
'409':
161+
description: There was a conflict when processing the request, usually due to a saved object with the same id
162+
content:
163+
application/json:
164+
schema:
165+
type: object
166+
'500':
167+
description: An internal server error occurred when processing the request
168+
content:
169+
application/json:
170+
schema:
171+
type: object
13172
/api/saved_objects/{type}/{id}:
14173
get:
15174
tags:
@@ -34,10 +193,10 @@ paths:
34193
post:
35194
tags:
36195
- saved objects
37-
summary: Create a new saved object with type and id.
196+
summary: Create a new saved object with a specific ID
38197
parameters:
39-
- $ref: '#components/parameters/type'
40-
- $ref: '#components/parameters/id'
198+
- $ref: '#/components/parameters/type'
199+
- $ref: '#/components/parameters/id'
41200
- in: query
42201
name: overwrite
43202
description: If set to true, will overwrite the existing saved object with same type and id.
@@ -137,13 +296,25 @@ paths:
137296
application/json:
138297
schema:
139298
$ref: '#/components/schemas/400_bad_request'
299+
'409':
300+
description: There was a conflict when processing the request, usually due to a saved object with the same id
301+
content:
302+
application/json:
303+
schema:
304+
type: object
305+
'500':
306+
description: An internal server error occurred when processing the request
307+
content:
308+
application/json:
309+
schema:
310+
type: object
140311
put:
141312
tags:
142313
- saved objects
143314
summary: Update existing saved object
144315
parameters:
145-
- $ref: '#components/parameters/type'
146-
- $ref: '#components/parameters/id'
316+
- $ref: '#/components/parameters/type'
317+
- $ref: '#/components/parameters/id'
147318
requestBody:
148319
required: true
149320
content:
@@ -188,8 +359,8 @@ paths:
188359
- saved objects
189360
summary: Delete a saved object
190361
parameters:
191-
- $ref: '#components/parameters/type'
192-
- $ref: '#components/parameters/id'
362+
- $ref: '#/components/parameters/type'
363+
- $ref: '#/components/parameters/id'
193364
- in: query
194365
name: force
195366
description: If set to true, will force deletion of an object that exists in multiple namespaces.
@@ -526,7 +697,7 @@ paths:
526697
content:
527698
application/json:
528699
schema:
529-
type: object
700+
type: object
530701
/api/saved_objects/_import:
531702
post:
532703
tags:
@@ -830,38 +1001,3 @@ paths:
8301001
application/json:
8311002
schema:
8321003
$ref: '#/components/schemas/400_bad_request'
833-
components:
834-
parameters:
835-
type:
836-
name: type
837-
in: path
838-
description: The type of SavedObject to retrieve.
839-
required: true
840-
schema:
841-
type: string
842-
id:
843-
name: id
844-
in: path
845-
description: Unique id of the saved object.
846-
required: true
847-
schema:
848-
type: string
849-
schemas:
850-
400_bad_request:
851-
title: Bad request
852-
type: object
853-
required:
854-
- error
855-
- message
856-
- statusCode
857-
properties:
858-
error:
859-
type: string
860-
enum:
861-
- Bad Request
862-
message:
863-
type: string
864-
statusCode:
865-
type: integer
866-
enum:
867-
- 400

0 commit comments

Comments
 (0)